By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,796 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,796 IT Pros & Developers. It's quick & easy.

How can I find the type of control through reflection

P: n/a
Hi All,
I need to find out the types of control (i-e Combo Box , List box etc.)
contained in a container. I can get the Type class but this only tells
whether it is a class or a interface and so on. It does not tell about the
actual type. Any clue? Issubclassof can be useful but do not have any idea
how to use it to get the actual type.

Regards,
Shahzad Atta
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I can get the Type class but this only tells
whether it is a class or a interface and so on. It does not tell about the
actual type.


Sure it does. You can for example write

if ( theType == typeof(ComboBox) ) ...

but if you have a reference to the control object you can also do

if ( theControl is ComboBox ) ...

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2

P: n/a
Did you try TypeOf, as in: If TypeOf ctl Is ComboBox Then...

"Shahzad Atta" <sh*****@nxvt.com> wrote in message
news:ee**************@TK2MSFTNGP14.phx.gbl...
Hi All,
I need to find out the types of control (i-e Combo Box , List box etc.)
contained in a container. I can get the Type class but this only tells
whether it is a class or a interface and so on. It does not tell about the
actual type. Any clue? Issubclassof can be useful but do not have any idea
how to use it to get the actual type.

Regards,
Shahzad Atta

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.