Solved

How to determine the type of a derived class?

Posted on 2007-11-30
2
284 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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