[Mono-winforms-list] Is this possible? (casting Q)

Rafael Teixeira monoman at gmail.com
Tue May 25 09:25:17 EDT 2010


You need to use something like some of the Activator.CreateInstance
overloads, probably this one:
http://msdn.microsoft.com/en-us/library/d133hta4%28v=VS.100%29.aspx

But you need to deal with full-names "System.Windows.Forms.Label"
instead of just Label, but you'll have to make your helper classes
anyway to support your dynamic forms. Don't forget that you'll need to
parse and initialize also lots of properties for each control (a Label
without size,position and caption is pretty useless).

Have fun,

Rafael "Monoman" Teixeira
---------------------------------------
"To be creative means to be in love with life. You can be creative
only if you love life enough that you want to enhance its beauty, you
want to bring a little more music to it, a little more poetry to it, a
little more dance to it."
Osho



On Mon, May 24, 2010 at 8:14 PM, Paul <paul at all-the-johnsons.co.uk> wrote:
> Hi,
>
> Is it possible to create a winform object using something stored in a
> string?
>
> 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  -  Mono-winforms-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>
>


More information about the Mono-winforms-list mailing list