Ronald,
Are you sure you want to pass the name of the control to your function,
or the name of the type of the control? If you pass the name of the type of
the control (or a Type instance itself), then you can use reflection to get
the Type (if you pass a string) and then construct an instance of that type
using reflection.
If you pass simply a field name, you could use reflection, but you need
to know the class on which the field is declared as well as the instance
holding it in order to get the instance that you are referring to.
All in all, it's easier to just pass the type to your method, and
construct an instance from there.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Ronald S. Cook" <rc***@westinis.comwrote in message
news:uG*************@TK2MSFTNGP04.phx.gbl...
>I want to something as simple as:
UserControl uctTemp;
But the type will be passed in to the function (which will be an existing
user control like "uctMyUserControl1")
So, how can I pass in the string "uctMyUserControl1" and then somehow dim
an instance of it?
uctMyUserControl1 uctTemp;
Thanks,
Ron