Solved

How to determine the type of a derived class?

Posted on 2007-11-30
2
285 Views
Last Modified: 2011-09-20
Hi:

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?

0
Comment
Question by:jxbma
2 Comments
 
LVL 11

Accepted Solution

by:
Babycorn-Starfish earned 500 total points
ID: 20383287
try

if( control is ClassName)
0
 
LVL 1

Author Closing Comment

by:jxbma
ID: 31411953
Thanks man... I should have known this.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question