473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Inheritance/Event Firing

Here a simple one. (At least I think it is?) and any help would be truly
appreciated.

I have an inherited textbox on my form based on a custom texbox control. It
looks something like this (I'll keep it simple)

Base Class:
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBoxBase1.TextChanged
MsgBox("In the form")
End Sub
I want to see how I can prevent the base classes ontextchanged event from
firing and override the base's code and handle everything on the form. I'm
sure it's probably a simple question, but for a fairly new .net'er , it got
me stumped...
Nov 20 '05 #1
6 7100
Hello,

"crk2" <yx**@xxxyyy.com> schrieb:
Here a simple one. (At least I think it is?) and any help would be truly
appreciated.

I have an inherited textbox on my form based on a custom texbox control. It looks something like this (I'll keep it simple)

Base Class:
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Remove the line above.
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBoxBase1.TextChanged
MsgBox("In the form")
End Sub

I want to see how I can prevent the base classes ontextchanged event from
firing and override the base's code and handle everything on the form. I'm sure it's probably a simple question, but for a fairly new .net'er , it got me stumped...


See inline comment.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
The base's OnTextChanged method will raise the event, so you don't want to
be doing that. Take out MyBase.OnTextChanged(e)

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
"crk2" <yx**@xxxyyy.com> wrote in message
news:VB*********************@news4.srv.hcvlny.cv.n et...
Here a simple one. (At least I think it is?) and any help would be truly
appreciated.

I have an inherited textbox on my form based on a custom texbox control. It looks something like this (I'll keep it simple)

Base Class:
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBoxBase1.TextChanged
MsgBox("In the form")
End Sub
I want to see how I can prevent the base classes ontextchanged event from
firing and override the base's code and handle everything on the form. I'm sure it's probably a simple question, but for a fairly new .net'er , it got me stumped...

Nov 20 '05 #3
Thanks for assistance, but I am still running into a wall. (I guess you
could blame it on my ignorance). So I applogize in advance for drilling down
deaper into this one.

If I remove the MyBase.OnTextChanged(e) then wouldn't the base class be
raised rather then the form's event? I guess what I am trying to do (10,
000 foot view) is to have a generic routine in the base class that handles
my dataset updates. Let's say in the textbox_leave event of the base class.
However, I only want this event to be raised when control validation (on the
inherited form) has been performed. Let's say that this is done on the
inherited control. Something like this:
On the form: (I'll keep it simple again)
Private Sub TextBoxBase1_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBoxBase1.Leave
'Handle control validaion (I.e. not empty or check if the text changed)
'If we pass then call then raise the base event to update the dataset
'else get the heck outta here
End Sub

Base class:
Protected Overrides Sub OnLeave(ByVal e As System.EventArgs)
'perform the update
End Sub

Thanks again
Regards
-Chris
P.S. In VFP I've worked with nodefault/dodefault to handle situations like
these. A simple nodefault --> run my validation --> dodefault() would do the
trick.
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
Hello,

"crk2" <yx**@xxxyyy.com> schrieb:
Here a simple one. (At least I think it is?) and any help would be truly appreciated.

I have an inherited textbox on my form based on a custom texbox control.

It
looks something like this (I'll keep it simple)

Base Class:
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)


Remove the line above.
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxBase1.TextChanged
MsgBox("In the form")
End Sub

I want to see how I can prevent the base classes ontextchanged event from firing and override the base's code and handle everything on the form.

I'm
sure it's probably a simple question, but for a fairly new .net'er , it

got
me stumped...


See inline comment.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet

Nov 20 '05 #4
I have no idea what nodefault, my validation, dodefault does. But, a guess
at what they do, says that you should be doing this:

<WatchForWrapping>

Protected Overrides Sub OnLeave(ByVal e as System.EventArgs)
' Do your Validation
' Now run the Base Class:
MyBase.OnLeave(e)
End Sub

</WatchForWrapping>

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
"crk2" <yx**@xxxyyy.com> wrote in message
news:eV*********************@news4.srv.hcvlny.cv.n et...
Thanks for assistance, but I am still running into a wall. (I guess you
could blame it on my ignorance). So I applogize in advance for drilling down deaper into this one.

If I remove the MyBase.OnTextChanged(e) then wouldn't the base class be
raised rather then the form's event? I guess what I am trying to do (10,
000 foot view) is to have a generic routine in the base class that handles
my dataset updates. Let's say in the textbox_leave event of the base class. However, I only want this event to be raised when control validation (on the inherited form) has been performed. Let's say that this is done on the
inherited control. Something like this:
On the form: (I'll keep it simple again)
Private Sub TextBoxBase1_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBoxBase1.Leave
'Handle control validaion (I.e. not empty or check if the text changed) 'If we pass then call then raise the base event to update the dataset
'else get the heck outta here
End Sub

Base class:
Protected Overrides Sub OnLeave(ByVal e As System.EventArgs)
'perform the update
End Sub

Thanks again
Regards
-Chris
P.S. In VFP I've worked with nodefault/dodefault to handle situations like
these. A simple nodefault --> run my validation --> dodefault() would do the trick.
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
Hello,

"crk2" <yx**@xxxyyy.com> schrieb:
Here a simple one. (At least I think it is?) and any help would be truly appreciated.

I have an inherited textbox on my form based on a custom texbox
control.
It
looks something like this (I'll keep it simple)

Base Class:
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Remove the line above.
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TextBoxBase1.TextChanged
MsgBox("In the form")
End Sub

I want to see how I can prevent the base classes ontextchanged event from firing and override the base's code and handle everything on the form.

I'm
sure it's probably a simple question, but for a fairly new .net'er ,

it got
me stumped...


See inline comment.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


Nov 20 '05 #5
Thnks Tom. I won't bore you with the details of the dodefault/nodefault and
VFP events. You put me on the right track though and I'll continue to look
into your suggested steps, but I ended up using a switch (via a property) to
determine if the even should being raised. Looks like its doing the trick.
(albiet, it may be a temporary workaround) until I can get a handle on my
event raising qaundry.

Thanks again Tom
Regards
Chris
"Tom Spink" <th**********@ntlworld.com> wrote in message
news:Om**************@tk2msftngp13.phx.gbl...
I have no idea what nodefault, my validation, dodefault does. But, a guess
at what they do, says that you should be doing this:

<WatchForWrapping>

Protected Overrides Sub OnLeave(ByVal e as System.EventArgs)
' Do your Validation
' Now run the Base Class:
MyBase.OnLeave(e)
End Sub

</WatchForWrapping>

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
"crk2" <yx**@xxxyyy.com> wrote in message
news:eV*********************@news4.srv.hcvlny.cv.n et...
Thanks for assistance, but I am still running into a wall. (I guess you
could blame it on my ignorance). So I applogize in advance for drilling

down
deaper into this one.

If I remove the MyBase.OnTextChanged(e) then wouldn't the base class be
raised rather then the form's event? I guess what I am trying to do (10,
000 foot view) is to have a generic routine in the base class that handles my dataset updates. Let's say in the textbox_leave event of the base

class.
However, I only want this event to be raised when control validation (on

the
inherited form) has been performed. Let's say that this is done on the
inherited control. Something like this:
On the form: (I'll keep it simple again)
Private Sub TextBoxBase1_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBoxBase1.Leave
'Handle control validaion (I.e. not empty or check if the text

changed)
'If we pass then call then raise the base event to update the dataset 'else get the heck outta here
End Sub

Base class:
Protected Overrides Sub OnLeave(ByVal e As System.EventArgs)
'perform the update
End Sub

Thanks again
Regards
-Chris
P.S. In VFP I've worked with nodefault/dodefault to handle situations like these. A simple nodefault --> run my validation --> dodefault() would do

the
trick.
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
Hello,

"crk2" <yx**@xxxyyy.com> schrieb:
> Here a simple one. (At least I think it is?) and any help would be

truly
> appreciated.
>
> I have an inherited textbox on my form based on a custom texbox

control. It
> looks something like this (I'll keep it simple)
>
> Base Class:
> Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
> MyBase.OnTextChanged(e)

Remove the line above.

> MsgBox("In the class")
> End Sub
>
> Inherited Object (on the form):
> Public Sub TextBoxBase1_TextChanged(ByVal sender As System.Object, ByVal
e
> As System.EventArgs) Handles TextBoxBase1.TextChanged
> MsgBox("In the form")
> End Sub
>
> I want to see how I can prevent the base classes ontextchanged event

from
> firing and override the base's code and handle everything on the form. I'm
> sure it's probably a simple question, but for a fairly new .net'er ,

it got
> me stumped...

See inline comment.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet



Nov 20 '05 #6
Hello,

"crk2" <yx**@xxxyyy.com> schrieb:
my dataset updates. Let's say in the textbox_leave event of
the base class.
However, I only want this event to be raised when control
validation (on the inherited form) has been performed. Let's say
that this is done on the inherited control. Something like this:
On the form: (I'll keep it simple again)
Private Sub TextBoxBase1_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBoxBase1.Leave
'Handle control validaion (I.e. not empty or check if the text changed) 'If we pass then call then raise the base event to update the dataset
'else get the heck outta here
End Sub

Base class:
Protected Overrides Sub OnLeave(ByVal e As System.EventArgs)
'perform the update
\\\
If <validation successful> Then
MyBase.OnLeave(e)
End If
///
End Sub


Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
0
by: Ram | last post by:
I have a start page for my application default.htm which contains four frames. header.htm login.aspx rightside.htm footer.htm login.aspx conatins username, password fields and login button....
2
by: Dave | last post by:
Hi, this is a follow-up to an earlier question but I really haven't found a definitive answer in my search If I have a Base and Derived webform, I've found that the dervived Page_Load event...
1
by: Diana | last post by:
I've got a database that has been working successfully for a number of years now. I just added a new item - basically a field that becomes visible depending on another field's value. When I was...
4
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my...
5
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the...
6
by: sjoshi | last post by:
I have a derived class OraBackup which has a method that calls stored procedure on Oracledb to get status of backup job. Now the base class publishes an event like this: public delegate void...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.