Hi:
My base form has a button, when click it will call MessageBox.Show (
"Base form" ). I inherite a child form from the base and assign a
button click event to the same button which will call MessageBox.Show (
"Inherited form" ). I run my application, and load the clild form,
click the button it show both message !!!
Is there any way to control the event sequence so that it only show
the child form event, or i can control whether to trigger the base
form event or not.
Thanks
JCVoon 4 2648
In the base form class, mark the routine as Overridable:
Public Overridable Sub Button1_Click(. ..) Handles ...
In the inherited class
Public Overrides Sub Button1_Click(. ..)
Do not use the Handles statement in the inherited form.
To get the base form code to process, add this code to the event handler in
the inherited form:
MyBase.Button1_ Click(Nothing, Nothing) www.charlesfarriersoftware.com
"JC Voon" wrote: Hi:
My base form has a button, when click it will call MessageBox.Show ( "Base form" ). I inherite a child form from the base and assign a button click event to the same button which will call MessageBox.Show ( "Inherited form" ). I run my application, and load the clild form, click the button it show both message !!! Is there any way to control the event sequence so that it only show the child form event, or i can control whether to trigger the base form event or not.
Thanks JCVoon
"JC Voon" <jc*******@yaho o.com> schrieb: My base form has a button, when click it will call MessageBox.Show ( "Base form" ). I inherite a child form from the base and assign a button click event to the same button which will call MessageBox.Show ( "Inherited form" ). I run my application, and load the clild form, click the button it show both message !!!
You may want to remove the handler added in the base class in the derived
class:
\\\
RemoveHandler Me.Button1.Clic k, AddressOf MyBase.Button1_ Click
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Hi JC
I would deal with this by having a Protected Overridable method in your base
class, and in your event handler, call this method. Then in the derived
class, override the method.
Base Form:
Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
ClickThing()
End Sub
Protected Overridable Sub ClickThing()
MessageBox.Show ("base")
End Sub
Derived Form:
Protected Overrides Sub ClickThing()
MessageBox.Show ("derived")
End Sub
HTH
Nigel Armstrong
"JC Voon" wrote: Hi:
My base form has a button, when click it will call MessageBox.Show ( "Base form" ). I inherite a child form from the base and assign a button click event to the same button which will call MessageBox.Show ( "Inherited form" ). I run my application, and load the clild form, click the button it show both message !!! Is there any way to control the event sequence so that it only show the child form event, or i can control whether to trigger the base form event or not.
Thanks JCVoon
Charlie, Herfried K. Wagner, Nigle Armstrong:
Thank for the reply. I've choose Charlie approch.
Is there any way to change the way IDE generate event ? If every event
is generate using public instead of private, it will save a lot of
work.
Cheers
JCVoon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rhy Mednick |
last post by:
I'm creating a custom control (inherited from UserControl) that is displayed
by other controls on the form. I would like for the control to disappear
when the user clicks outside my control the same way a menu does. To do
this my control needs to get notified when the user tried to click off of
it. The Leave and LostFocus events of the UserControl work most of the time
but not always. For example, if they click on a part of the form...
|
by: 42 |
last post by:
I implemented a simple class inherited from Page to create a page
template. It simply wraps some trivial html around the inherited page,
and puts the inherited page into a form.
The problem I have run into is that the emitted html at the end of the
process is slightly different and doesn't work.
Please don't be put off by all the source code. All the guts are in this
first base class, and it doesn't do much. The rest is trivial...
|
by: crk2 |
last post by:
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")
|
by: Sergey Poberezovskiy |
last post by:
Hi,
I created two base forms: frmList and frmDetail, compiled
them into a dll, and then want to use in my new project.
The problem: When I created new inherited form, say
frmClients, I cannot load the form in design view - the
IDE complains with
"Argument 'Path' is Nothing or empty." error.
It does not stop however the project to compile, and even
|
by: Altman |
last post by:
Ok I have a control that is inherited from another class. In the child I
put msgbox(me.name) in the load event. What always pops up is the name of
the parent class and not the name of the instance of the object. WHY? Also
if I can figure this out I'm hoping that I can put this in the load event of
the parent and still get it to work.
| |
by: Rod Gill |
last post by:
Hi,
I have a form that when opened in the designer appears of the screen. The
form selector can't be dragged (or resized) and if I scroll right and down
to centralise it the form simply jumps further away, completely leaving the
selector box area.
Any ideas? VS 2003 and VB.Net
This is a simple application at the moment but the form is inherited from a
|
by: asad.naeem |
last post by:
hi to all
this is the problem about inheritence. I have designed a form with some
essential controls which are required for every form which will
inherited from it. for example i have Button1 on parent form and this
button is visible to me on inherited form.
The problem is:
I have written a click event of the button1 on both of the forms. tell
me the way if i click the button on inherited form only parents' click
event will be called and...
|
by: Joel |
last post by:
2 Questions:
(1)
The documentation says application.run() creates a standard
message loop on the current thread and "optionally" shows a
form. This is really confusing because I was of the understanding
that application.run() creates a message loop for the form and
passes all messages to it.
If showing the form is optional, and I want to to display 2 forms,
which form will application.run() pass the windows messages to?
|
by: fahimrauf |
last post by:
Hy Friends,
Using visual inheritance feature of .net, I've inherited a Form (Form2) from an existing form (Form1) of the same assembly or project. It's perfectly inherited and when I run the application it's executing fine. But when I open the inherited form (Form2) in designer, It throws an exception in form_load event of Parent Form (Form1) as code block in form_load event requires some data which will be available only when application...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |