473,395 Members | 1,869 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,395 software developers and data experts.

A fired event bug in VB.net 2003?!

Hi, everyone. I get a very interesting thing in VB.net
2003.

First you create a base form, and then add a button in
the baseform. Write an overridable function to fire a
event when the buton is clicked. I just write the
following code:
Overridable sub btnOK_Click(...) handles btnOK.click
me.close
End sub

Second you create a new form. inherit it from the base
form. Make a new override function about the button OK. I
just write down:
Overrides sub btnOK_Click(...) handles btnOK.click
msgbox("Oh, no",...)
End sub

Finally you run this project, and click the button in the
child form. You will find the msgbox pops out twice, which
means the override function executes twice!
..
Nov 20 '05 #1
1 1792
"Yuanxi Liu" <ma*********@hotmail.com> schrieb
Hi, everyone. I get a very interesting thing in VB.net
2003.

First you create a base form, and then add a button in
the baseform. Write an overridable function to fire a
event when the buton is clicked. I just write the
following code:
Overridable sub btnOK_Click(...) handles btnOK.click
me.close
End sub

Second you create a new form. inherit it from the base
form. Make a new override function about the button OK. I
just write down:
Overrides sub btnOK_Click(...) handles btnOK.click
msgbox("Oh, no",...)
End sub

Finally you run this project, and click the button in the
child form. You will find the msgbox pops out twice, which
means the override function executes twice!
.


That's how I'd expect it to be. You add two event handlers by using the
Handles keyword twice. The Handles statement in the base form points to
btnOk_Click, but as it is "overriden" in the derived Form, the procedure in
the derived form is added as an event handler. The second time you add the
handler is in the derived Form because there is another Handles keyword. It
also points to the procedure in the derived form, so your msgbox comes
twice.
--
Armin

Nov 20 '05 #2

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

Similar topics

4
by: Anatoly | last post by:
Put any control on web page. create Init event for ths control. Write Response.Write("here") inside this event. Compile\build\run. I never saw "here" string appear on web page. Why???
6
by: Jeff User | last post by:
Hi I have a WebControls.DropDownList. autoPostBack is set to true. I have code (C#) in the event procedure in the code behind and it works fine. OK, now my problem is this: While in the...
0
by: Yushan | last post by:
Hi all, We have a C# WinForm app that has a WebBrowser control on one of its forms, and we have code in its DocumentComplete event. The events gets fired in our development machines (with VS...
1
by: NAT | last post by:
I make a response.redirect to an ABC.aspx page from my web application. In the Page Load event of the ABC.aspx page I make a call to a web method of a web service.But what I notice here is that...
0
by: Artur | last post by:
I'm trying to write a code that will change prefix (http to https and vice versa). It half works now, because I can reach Application_BeginRequest method in Global.asax file only when NOT in...
0
by: Artur | last post by:
After trying to solve this, I noticed another strange thing. When in secure connection Page_Load method of page is not invoked (Load event not fired). I looked where this method is assigned to this...
2
by: AMDRIT | last post by:
Hello Everyone, I am having an issue where an event appears to be fired repeatedly where I only expect it to be fired once. See below for objects and behaviors. I have a control that contains...
3
by: axxon | last post by:
Hi guys! I am at my wits end detecting which one of the dymically loaded button fired the click event(since they all have same ID and text value) Heres the scenario: I have created a loop to read...
4
by: since | last post by:
How do I in IE prevent the onclick action from being fired when I am done dragging? have tried "window.event.cancelBubble = true", for onmouseup , onmousedown, and onmousemove handlers. The onclick...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.