C# winforms cast childform as of it's own type -


i have mdi project. i'm using form activeform = this.activemdichild;

however, instead of form, i'm like:

forms.lookup.grade activeform = (forms.lookup.grade) this.activemdichild; forms.lookup.product activeform = (forms.lookup.product) this.activemdichild; 

...etc

so if forms.lookup.grade active want return activeform forms.lookup.grade

how can cast active form of it's own type in generic way instead of using switch this.activemdichild.name ?

thank mansi

you can check type @ runtime:

form activeform = this.activemdichild; if(activeform forms.lookup.grade) {   forms.lookup.grade gradeform = activeform forms.lookup.grade;   gradeform.somemethodofgrade();   .... } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -