473,473 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Inheritance doubt.

Hello All,

I am planning to use inheritance for forms which have similar controls
and properties. I tried to do it with a small example, but I am facing
some issues.

I created a base form (with 2 butttons) with overridable event
procedures. In the inheritance I created a 2 overriding event
procedures. The startup object was the base form. In the base form
button2 procedure I am calling the inherited form. The inherited form
loads but the inherited form button2 procedure fires twice. Why is
that? Please help me.

thank you in advance.

Ravi

Mar 10 '06 #1
2 792

Ravimama wrote:
Hello All,

I am planning to use inheritance for forms which have similar controls
and properties. I tried to do it with a small example, but I am facing
some issues.

I created a base form (with 2 butttons) with overridable event
procedures. In the inheritance I created a 2 overriding event
procedures. The startup object was the base form. In the base form
button2 procedure I am calling the inherited form. The inherited form
loads but the inherited form button2 procedure fires twice. Why is
that? Please help me.


I suspect you might be doing this:

base form:
Overrideable Sub Button2_Click(sender, e) Handles Button2.Click
'base button2 click behaviour
End Sub

derived form:
Overrides Sub Button2_Click(sender, e) Handles Button2.Click
'derived button2 click behaviour
End Sub

Because there are two Handles clauses, they will BOTH be called on
Button2.Click. What you should do is this:

base form:
Sub Button2_Click(sender, e) Handles Button2.Click
OnButton2Click
End Sub

Protected Overrideable Sub OnButton2Click()
'base button2 click behaviour
End Sub

derived form:
Overrides Sub OnButton2Click()
'maybe:
MyBase.OnButton2Click
'derived button2 click behaviour
End Sub

--
Larry Lard
Replies to group please

Mar 10 '06 #2
Thanks mate! It worked. This is what I was looking for.

Mar 10 '06 #3

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

Similar topics

4
by: KInd | last post by:
Hello All, When is nested class more preferable that Inheritance ? I think with proper inheritance and friend class concept we can get the same flexibility as nested classes Any comments .. Best...
10
by: Ioannis Vranos | last post by:
May someone explain why does this compile? class HiddenSealBaseClass { public: HiddenSealBaseClass() { } }; class Sealed: virtual HiddenSealBaseClass
2
by: Søren Holstebroe | last post by:
Hi there, I'm having a struggle with GNU g++ (3.3.5) and inheritance of typedefs in STL containers. I'm trying to port some old code I wrote with MS Visual C++ and it looks like there is a...
3
by: darkstorm | last post by:
I have a doubt regarding inheritance involving templates Consider this: ///////////////////////////////////// template<typename T> class A { private: T m_a;
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
5
by: colint | last post by:
Hi I'm fairly new to c++ and I have a question regarding inheritance. I'm trying to create a class based on 2 inherited classes, e.g. class A { ... } class B: public A
1
by: Gary Wessle | last post by:
Hi is there some guide lines on how many level deep once can structure the inheritance, I have 3 level deep inheritance setup and just wondering whether this is the norm? each level is...
4
by: Anarki | last post by:
##include <iostream> using namespace std; class A { }; class B:virtual public A { }; class C:virtual public A
7
by: pradeep | last post by:
Hello friends: In the following setup, class A { ... }; class B { ...
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
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...
0
jinu1996
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...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.