How can I find the type of control through reflection

  • Thread starter Thread starter Shahzad Atta
  • Start date Start date
S

Shahzad Atta

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
 
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
 
Did you try TypeOf, as in: If TypeOf ctl Is ComboBox Then...

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
 
Back
Top