By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,068 Members | 867 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,068 IT Pros & Developers. It's quick & easy.

Problems with referencing the instance of an Inherited Textbox

P: n/a
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
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200510/1
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mac,

Did you ever look at the binding events. I get the idea that when you have a
good look at that, that you than probably leave your current approach

Have a (good) look at our VB-Tips website for that

http://www.vb-tips.com/default.aspx?...9-4deb7fa4a0b8

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
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...
"Mac via DotNetMonster.com" wrote:
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
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200510/1

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.