Problems with referencing the instance of an Inherited Textbox

  • Thread starter Mac via DotNetMonster.com
  • Start date
M

Mac via DotNetMonster.com

Hi all,

I have created my own class DateBox which inherits from the System.Windows.
Forms.TextBox class. In this DateBox class I catch the validating event so
that I can run some code to validate and format the date that was entered on
the form.

I catch this event as follows:

Private Sub DateBox_Validating(ByVal sender As Object, ByVal e As _
System.ComponentModel.CancelEventArgs) Handles MyBase.Validating

But I need to know the current instance of the DateBox because I would like
to set the toolttip for the current instance of the DateBox to be the long
date for the short date entered. MyBase is no good for this.

If there anyway to reference the current instance of the textbox? I think I
will have to do everything I want in a user control rather than an inherited
class.

regards,

Mac
 
G

Guest

You can access the base clase by using the MyBase object that is predefined
in Visual Basic.

Unfortunately you can't really sink events using MyBase. But instead you
can override the OnValidating method and provide your own implementation.
Just make sure to call MyBase.OnValidating in your overriding method so the
base class gets a chance to do it's 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