473,651 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(B yVal e As System.EventArg s)
MyBase.OnTextCh anged(e)
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_Te xtChanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TextBoxBase1.Te xtChanged
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 7131
Hello,

"crk2" <yx**@xxxyyy.co m> 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(B yVal e As System.EventArg s)
MyBase.OnTextCh anged(e)
Remove the line above.
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_Te xtChanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TextBoxBase1.Te xtChanged
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.OnTextCh anged(e)

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

Please respond to the newsgroup,
so all can benefit
"crk2" <yx**@xxxyyy.co m> wrote in message
news:VB******** *************@n ews4.srv.hcvlny .cv.net...
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(B yVal e As System.EventArg s)
MyBase.OnTextCh anged(e)
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_Te xtChanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles TextBoxBase1.Te xtChanged
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.OnTextCh anged(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_Le ave(ByVal sender As Object, ByVal e As
System.EventArg s) Handles TextBoxBase1.Le ave
'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.EventArg s)
'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.ac tivevb.de> wrote in message
news:eP******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

"crk2" <yx**@xxxyyy.co m> 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(B yVal e As System.EventArg s)
MyBase.OnTextCh anged(e)


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

Inherited Object (on the form):
Public Sub TextBoxBase1_Te xtChanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles TextBoxBase1.Te xtChanged
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:

<WatchForWrappi ng>

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

</WatchForWrappin g>

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

Please respond to the newsgroup,
so all can benefit
"crk2" <yx**@xxxyyy.co m> wrote in message
news:eV******** *************@n ews4.srv.hcvlny .cv.net...
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.OnTextCh anged(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_Le ave(ByVal sender As Object, ByVal e As
System.EventArg s) Handles TextBoxBase1.Le ave
'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.EventArg s)
'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.ac tivevb.de> wrote in message
news:eP******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

"crk2" <yx**@xxxyyy.co m> 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(B yVal e As System.EventArg s)
MyBase.OnTextCh anged(e)
Remove the line above.
MsgBox("In the class")
End Sub

Inherited Object (on the form):
Public Sub TextBoxBase1_Te xtChanged(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles TextBoxBase1.Te xtChanged
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**********@n tlworld.com> wrote in message
news:Om******** ******@tk2msftn gp13.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:

<WatchForWrappi ng>

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

</WatchForWrappin g>

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

Please respond to the newsgroup,
so all can benefit
"crk2" <yx**@xxxyyy.co m> wrote in message
news:eV******** *************@n ews4.srv.hcvlny .cv.net...
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.OnTextCh anged(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_Le ave(ByVal sender As Object, ByVal e As
System.EventArg s) Handles TextBoxBase1.Le ave
'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.EventArg s)
'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.ac tivevb.de> wrote in message
news:eP******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

"crk2" <yx**@xxxyyy.co m> 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(B yVal e As System.EventArg s)
> MyBase.OnTextCh anged(e)

Remove the line above.

> MsgBox("In the class")
> End Sub
>
> Inherited Object (on the form):
> Public Sub TextBoxBase1_Te xtChanged(ByVal sender As System.Object, ByVal
e
> As System.EventArg s) Handles TextBoxBase1.Te xtChanged
> 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.co m> 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_Le ave(ByVal sender As Object, ByVal e As
System.EventArg s) Handles TextBoxBase1.Le ave
'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.EventArg s)
'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
7472
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 it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the frontend) will stop firing until the user gives the form focus. (Note that the update itself always...
14
12118
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 events since I never saw it used anywhere in MSDN documentation/samples?! Or it will just break when I upgrade to .NET Framework 2.x in the coming years namespace MyNamespac public delegate void MyDel() public class MyBase public virtual...
0
1683
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. When the login is successful login page writes back javascript
2
2211
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 fires first, then the base Page_Load. Is the only technique to change this sequence is to override the Base.Page_Load and explicitely call the base event when you want to as below: Derived WebForm
1
5058
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 testing this, I noticed that the OnCurrent event wasn't firing. I went to an older version of the program and saw that it wasn't firing there either. I don't know how long this has been going on, but it's quite distressing. To test the firing, I...
4
4189
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 controls as custom server controls and don't understand why this event won't fire. I figured if the creation of the control was in the init, it would be initialized and have its event handlers set up, then after Load, the control would call its...
5
4528
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 onmouseleave / onmouseout event I've attached to my hidden drop down (in this case an <ul>), is not firing correctly. It seems that when the mouse enters the ul it fires the mouseleave event. The problem is in the hideMenu2(e) function. I'm copying...
6
19266
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 PercentEventHandler(object sender, JobCompletedEventArgs e); public event PercentEventHandler PercentCompleted; And fires it:
2
3910
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 well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever possible to make the app more efficient and less resource demanding. On one page there are 2...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.