Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

How to override a textbox event?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cylix - 27 Feb 2008 01:07 GMT
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!
Armin Zingler - 27 Feb 2008 01:46 GMT
> 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
Cor Ligthert[MVP] - 27 Feb 2008 05:53 GMT
Cylix-

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

-Cor

>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 - 03 Mar 2008 07:13 GMT
> 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.
Phill W. - 27 Feb 2008 11:59 GMT
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.