المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Extending a .Net Control. Implement new functionality in event



C# Programming
06-28-2010, 01:00 AM
Hello,
I want to create some custom groupboxes. What I did is created a new class called MyGroupBox that is derived from System.Windows.Forms.GroupBox .

Everything is going great but I have a problem. I want to overwrite the default OnEnabledChanged event and add a new feature.

What I did is this:
protected override void OnEnabledChanged(EventArgs e)
{
if (this.Enabled)
{
this.ColorScheme = EnmColorScheme.Purple;
}
else {
this.ColorScheme = EnmColorScheme.Green;
}
}
Now what this will do is change the color of a disaled groupbox. The problem is that if I do this, the default functionality dissapers. When disabling a groupbox, all controls from the groupbox should be disabled. If I override the event, than his does not happen.

What can I do to make the event behave like in the past, but also hadd my functionality (to add colors).

I don't wan to implement this in every object that I created, that's why I am doing it in the main class "MyGroupBox".

Any help is greatly appreciated.

Thanks!
Vlad