PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
How to get a Form object through the form name
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
How to get a Form object through the form name
![]() |
How to get a Form object through the form name |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I need to get a form instance, by supplying the form name i.e, i need some thing similar to Class.forName() in Java. I tried it using System.Type.GetType() method passing the form name as object. But the prob here is i'm getting an exception saying "System.Type can not be casted to a System.Windows.Form". How can i get the form object based on the form name. Any one plz suggest. Thanks, Hari |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Use a variation of my GetControlByName function:
http://blog.opennetcf.org/ctacke/Pe...1a-2ae2de4bdaf1 -- Chris Tacke OpenNETCF Consulting Managed Code in the Embedded World www.opennetcf.com -- "Hari" <hadusumalli@mantragroup.com> wrote in message news:1158065775.428204.317710@e63g2000cwd.googlegroups.com... > Hi, > I need to get a form instance, by supplying the form name i.e, i > need some thing similar to Class.forName() in Java. I tried it using > System.Type.GetType() method passing the form name as object. But the > prob here is i'm getting an exception saying "System.Type can not be > casted to a System.Windows.Form". How can i get the form object based > on the form name. Any one plz suggest. > > Thanks, > > Hari > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Hi Chris,
Thanks for the suggestion. I've already downloaded your class previously. That was working fine, but for controls other than a Form. As you have used Parent property which is null for a Form, this does not work on a Form as it is. Please suggest what has to be modified to make it work for a Form. <ctacke/> wrote: > Use a variation of my GetControlByName function: > > http://blog.opennetcf.org/ctacke/Pe...1a-2ae2de4bdaf1 > > > -- > Chris Tacke > OpenNETCF Consulting > Managed Code in the Embedded World > www.opennetcf.com > -- > > > "Hari" <hadusumalli@mantragroup.com> wrote in message > news:1158065775.428204.317710@e63g2000cwd.googlegroups.com... > > Hi, > > I need to get a form instance, by supplying the form name i.e, i > > need some thing similar to Class.forName() in Java. I tried it using > > System.Type.GetType() method passing the form name as object. But the > > prob here is i'm getting an exception saying "System.Type can not be > > casted to a System.Windows.Form". How can i get the form object based > > on the form name. Any one plz suggest. > > > > Thanks, > > > > Hari > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

