How to override a textbox event?

  • Thread starter Thread starter Cylix
  • Start date Start date
C

Cylix

I would like to rewrite the textbox.click event.
But I cannot find the correct stuff on this matter, is it call
override?
Please give me some hints, Thanks!
 
Cylix said:
I would like to rewrite the textbox.click event.
But I cannot find the correct stuff on this matter, is it call
override?
Please give me some hints, Thanks!

What does "rewrite" mean? The Textbox raises the event in the OnClick
method (inherited from Control). You can override this method. Usually
the overriden method is called first:

Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
MyBase.OnClick(e)
End Sub



Armin
 
Cylix-

I am curious why (and for what) you want to do this, we want to learn here
you know.

-Cor
 
Cylix said:
I would like to rewrite the textbox.click event.

A questionable motive, but the principle's the same for all the events,
so here goes ...

Derive a custom TextBox class from the standard one, and override (or,
in the case, "extend" (/my/ term)) the processing for "Click" :

Class CustomTextBox
Inherits TextBox

Public Sub New()
End Sub

Protected Overrides Sub OnClick( _
e as EventArgs _
)
' Do some custom things here
' . . .

' Get the Click event raised to anyone /else/ who might be
' listening out for it
MyBase.OnClick( e )

' Do some more custom things here
' . . .

End Sub

HTH,
Phill W.
 
I am curious why (and for what) you want to do this, we want to learn here
you know.
No special usage actually, just would like to know is any method to do
so.
And, it looks easy.
Thanks all.
 
Back
Top