How to subclass in 2005

  • Thread starter Richard Lewis Haggard
  • Start date
R

Richard Lewis Haggard

In 2005, I tried to derive a class from Label but something is not quite
right.

To create the class in the first place, I right clicked on the project and
chose the Add->Class menu item. I then derived the class as

public class LabelGrid : Label

However, the overrides don't seem to be getting called. For example, the
background paint routine was defined as

protected override void OnPaintBackground(PaintEventArgs pevent)

So, what did I do wrong?
 
R

Richard Lewis Haggard

Oops. The problem was, after I created the label derived control, I did not
add it to the form's control collection.

Still, back in Dev Studio 6 and even in 2003, the IDE provided the means
whereby a virtual over ride can be added to a derived class without forcing
the programmer to manually enter anything. Is there some mechanism in 2005's
C# interface that does the same thing?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top