Re: Casting question (creating things on the fly)

Ivan Zlatev <[email protected]>
Newsgroups gmane.comp.gnome.winforms
Message-ID <[email protected]>
On Tue, May 25, 2010 at 7:13 AM, Paul <[email protected]> wrote:
>
> Hi,
>
> Is it possible to create a winform object using something stored in a
> string?

Take a look at Type.GetType(string) and Activator.CreateInstance
methods. Depending on how you do things you might also have to call
Assembly.Load to load the System.Windows.Forms assembly in the
appdomain.

>
> For example
>
> string m = "Label";
> object n = (object)m;
>
> n foo = new n();
>
> I'd imagine it can be, but after 20 mins of googling around, can't see
> anything that says I can...
>
> TTFN
>
> Paul
> --
> Biggles was quietly reading his favourite book when Algy burst through
> the door. Distracted for a moment, Biggles surveyed what had happened
> and turned a page. "Algy old man" he said, clearing his throat, "use the
> handle next time..." - Taken from "Biggles combs his Hair"
>
> _______________________________________________
> Mono-winforms-list maillist  -  [email protected]
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>
_______________________________________________
Mono-winforms-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.