Missing events in MyBase when using control inheritance

J

Jeremy.Deats

I have been programming in C# for the past few years and I'm now trying
to implement something in VB.NET (Framework 1.1) that I'm having a
problem with...

In C# I can create a new class and make it dervived from a Microsoft
Windows Forms control (e.g. TabControl), then in the constructor I can
add an event handler to the ControlAdded and ControlRemoved events like
so:

public Class1()
{
//
// TODO: Add constructor logic here
//

this.ControlAdded += new ControlEventHandler(Class1_ControlAdded);
this.ControlRemoved += new
ControlEventHandler(Class1_ControlRemoved);

}

The ControlAdded and ControlRemoved events are protected events of the
base class TabControl, when attempting this Using VB.NET it fails, for
example. This:


Private Sub TabControl1_ControlAdded(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.ControlAdded

End Sub

Creates a compile time error and Visual Studio.NET intellisense does
not show ControlAdded and ControlRemoved events as being available
events off of MyBase.

I would like to know if anyone can recommend a work around to this. I
really need to handle these two events in my dervived control.

Thanks.
 
H

Herfried K. Wagner [MVP]

Private Sub TabControl1_ControlAdded(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.ControlAdded

'System.EventArgs' => 'ControlEventArgs'.
 

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