How to determine the type of a derived class?


To encapsulate data, I've subclassed several of the winform controls:

TextBox --> EWTextBox;
ComboBox --> EWComboBox;
ListBox --> EWListBox;

For generic handling, I store my derived controls in a list based on their common base class:
EWList<Forms.Control> ewTransactionUtilityControls = new EWList<.Forms.Control>();

Later, when I'm processing the list later, I would like to determine the derived class so I can do special processing according to the derived class type:

foreach( Control control in EWList)
     // Figure out whether "control" is an EWTextBox, EWComboBox, EWListBox

How do I do that?

jxbmaSoftware ConsultantAsked:
Who is Participating?
Babycorn-StarfishConnect With a Mentor Commented:

if( control is ClassName)
jxbmaSoftware ConsultantAuthor Commented:
Thanks man... I should have known this.
All Courses

From novice to tech pro — start learning today.