473,830 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need an alternative to multiple inheritance

I have a control called MyPanel that inherits from Panel.
Also a control called MyRTB that inherits from RichTextBox.

They are used on a form as follows:

MyPanel in on the form and MyRTF is placed in MyPanel.

I do this so that the properties of MyRTF and of MyPanel are available to
the form.

What I'd rather do is have the MyPanel control contain MyRTF so only one
control need be used on the form.

Of course if I just do that the properties of MyRTF will not be available to
the form unless I make MyRTF public and use something like
MyPanel1.MyRTF1 .Text

It not nice the way I have it nor is the alternative mentioned above much
better.

Seems I've read that multiple inheritance is not needed because Interfaces
can be used instead, but I don't know how.

Is there a neat way to do what I need to do?
Thanks in advance
Dec 2 '05 #1
8 1386
Create a user control.Add MyPanel to the user control, add MyRTF inside the
panel.
Create properties inside this user control to expose whatever properties
need to be exposed for both the textbox and the panel.

Now you can use the user control on forms.

" **Developer**" <RE************ *@a-znet.com> wrote in message
news:ul******** ******@TK2MSFTN GP14.phx.gbl...
I have a control called MyPanel that inherits from Panel.
Also a control called MyRTB that inherits from RichTextBox.

They are used on a form as follows:

MyPanel in on the form and MyRTF is placed in MyPanel.

I do this so that the properties of MyRTF and of MyPanel are available to
the form.

What I'd rather do is have the MyPanel control contain MyRTF so only one
control need be used on the form.

Of course if I just do that the properties of MyRTF will not be available
to the form unless I make MyRTF public and use something like
MyPanel1.MyRTF1 .Text

It not nice the way I have it nor is the alternative mentioned above much
better.

Seems I've read that multiple inheritance is not needed because Interfaces
can be used instead, but I don't know how.

Is there a neat way to do what I need to do?
Thanks in advance

Dec 2 '05 #2
Thanks for the reply.
The number of properties is very large. I was hoping there might be another
way.

Thanks

"Marina" <so*****@nospam .com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Create a user control.Add MyPanel to the user control, add MyRTF inside
the panel.
Create properties inside this user control to expose whatever properties
need to be exposed for both the textbox and the panel.

Now you can use the user control on forms.

" **Developer**" <RE************ *@a-znet.com> wrote in message
news:ul******** ******@TK2MSFTN GP14.phx.gbl...
I have a control called MyPanel that inherits from Panel.
Also a control called MyRTB that inherits from RichTextBox.

They are used on a form as follows:

MyPanel in on the form and MyRTF is placed in MyPanel.

I do this so that the properties of MyRTF and of MyPanel are available to
the form.

What I'd rather do is have the MyPanel control contain MyRTF so only one
control need be used on the form.

Of course if I just do that the properties of MyRTF will not be available
to the form unless I make MyRTF public and use something like
MyPanel1.MyRTF1 .Text

It not nice the way I have it nor is the alternative mentioned above much
better.

Seems I've read that multiple inheritance is not needed because
Interfaces can be used instead, but I don't know how.

Is there a neat way to do what I need to do?
Thanks in advance


Dec 2 '05 #3
"Marina" <so*****@nospam .com> schrieb:
Create a user control.Add MyPanel to the user control, add MyRTF inside
the panel.
Create properties inside this user control to expose whatever properties
need to be exposed for both the textbox and the panel.

Now you can use the user control on forms.


Mhm... To do that, it's not even necessary to create a usercontrol. It's
sufficient to create a class which inherits from panel and adds a
richtextbox control to its 'Controls' collection. Then you can extend the
inherited panel by additional properties.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 2 '05 #4
Yes, you are right. I tend to think in terms of completely boxing up the
whole thing. So that if ever you decide you don't want a panel, but you want
a tab control, you just swap out the control in the user control, and
re-implement all the properties, and know that everything is still valid.
Whereas with a panel, panel specific properties may have ended up being set
directly on the consuming form.

But you are right, in most cases that wouldn't matter, and inheriting from
panel works fine.

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
"Marina" <so*****@nospam .com> schrieb:
Create a user control.Add MyPanel to the user control, add MyRTF inside
the panel.
Create properties inside this user control to expose whatever properties
need to be exposed for both the textbox and the panel.

Now you can use the user control on forms.


Mhm... To do that, it's not even necessary to create a usercontrol. It's
sufficient to create a class which inherits from panel and adds a
richtextbox control to its 'Controls' collection. Then you can extend the
inherited panel by additional properties.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 2 '05 #5
As Herfried suggested, you can inherit from Panel.

You can also expose the panel and richtextbox as properties, so that you can
set properties directly on the objects.

" **Developer**" <RE************ *@a-znet.com> wrote in message
news:u2******** *****@TK2MSFTNG P11.phx.gbl...
Thanks for the reply.
The number of properties is very large. I was hoping there might be
another way.

Thanks

"Marina" <so*****@nospam .com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Create a user control.Add MyPanel to the user control, add MyRTF inside
the panel.
Create properties inside this user control to expose whatever properties
need to be exposed for both the textbox and the panel.

Now you can use the user control on forms.

" **Developer**" <RE************ *@a-znet.com> wrote in message
news:ul******** ******@TK2MSFTN GP14.phx.gbl...
I have a control called MyPanel that inherits from Panel.
Also a control called MyRTB that inherits from RichTextBox.

They are used on a form as follows:

MyPanel in on the form and MyRTF is placed in MyPanel.

I do this so that the properties of MyRTF and of MyPanel are available
to the form.

What I'd rather do is have the MyPanel control contain MyRTF so only one
control need be used on the form.

Of course if I just do that the properties of MyRTF will not be
available to the form unless I make MyRTF public and use something like
MyPanel1.MyRTF1 .Text

It not nice the way I have it nor is the alternative mentioned above
much better.

Seems I've read that multiple inheritance is not needed because
Interfaces can be used instead, but I don't know how.

Is there a neat way to do what I need to do?
Thanks in advance



Dec 2 '05 #6
Thanks for the replies.

BTW I misspoke, the first two sentences of my post should have used "class"
instead of "control"

I use the IDE to place the MyPanel and then add MyRTF
Me.ControlPanel 1.Controls.Add( Me.ControlRichT extBox1)

I was hoping the panel could expose a RichTextBox interface or something.

thanks


" **Developer**" <RE************ *@a-znet.com> wrote in message
news:ul******** ******@TK2MSFTN GP14.phx.gbl...
I have a control called MyPanel that inherits from Panel.
Also a control called MyRTB that inherits from RichTextBox.

They are used on a form as follows:

MyPanel in on the form and MyRTF is placed in MyPanel.

I do this so that the properties of MyRTF and of MyPanel are available to
the form.

What I'd rather do is have the MyPanel control contain MyRTF so only one
control need be used on the form.

Of course if I just do that the properties of MyRTF will not be available
to the form unless I make MyRTF public and use something like
MyPanel1.MyRTF1 .Text

It not nice the way I have it nor is the alternative mentioned above much
better.

Seems I've read that multiple inheritance is not needed because Interfaces
can be used instead, but I don't know how.

Is there a neat way to do what I need to do?
Thanks in advance

Dec 2 '05 #7
" **Developer**" <RE************ *@a-znet.com> schrieb:
BTW I misspoke, the first two sentences of my post should have used
"class" instead of "control"

I use the IDE to place the MyPanel and then add MyRTF
Me.ControlPanel 1.Controls.Add( Me.ControlRichT extBox1)

I was hoping the panel could expose a RichTextBox interface or something.


No, that's not possible. You can either make a reference to the richtextbox
control available by your control or reimplement its public members and
delegate the calls to the richtextbox control.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 2 '05 #8
Thanks

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:OJ******** *****@TK2MSFTNG P15.phx.gbl...
" **Developer**" <RE************ *@a-znet.com> schrieb:
BTW I misspoke, the first two sentences of my post should have used
"class" instead of "control"

I use the IDE to place the MyPanel and then add MyRTF
Me.ControlPanel 1.Controls.Add( Me.ControlRichT extBox1)

I was hoping the panel could expose a RichTextBox interface or something.


No, that's not possible. You can either make a reference to the
richtextbox control available by your control or reimplement its public
members and delegate the calls to the richtextbox control.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 3 '05 #9

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

Similar topics

2
4341
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
5
2185
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should multiple inheritance still be avoided? If yes, why multiple inheritance is introducted into C++?
30
2735
by: Vla | last post by:
why did the designers of c++ think it would be more useful than it turned out to be?
20
10092
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in advance for enlightment ... here's the snippet #!/usr/bin/python
22
23391
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete examples?
47
3661
by: Mark | last post by:
why doesn't .NET support multiple inheritance? I think it's so silly! Cheers, Mark
60
4953
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 'target' programming community herein) to get some community input and verify (or not) the following two statements. Few programmers (3 to7%) UNDERSTAND 'Strategic Functional Migration
18
2347
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before. Here's the scenario: We have a base class with all virtual functions. We'll call this the Animal class. We then make two classes Fish and Bird that both inherit from Animal. In the program, we have a single array of Animal pointers that will...
2
2704
by: weird0 | last post by:
Suppose i have two classes A and B: class A { public method_a(); } class B
0
9777
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
10763
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
10473
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 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...
1
10518
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,...
0
6939
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();...
0
5614
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
5772
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4407
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
3
3070
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.