473,503 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inteface for Controls.Add(???)

Hi all,
how do I solve this problem:

Interface A
{...}

Class B : System.Windows.Forms.UserControl, A
{...}

ClassC : System.Windows.Forms.UserControl, A
{...}

Class D : System.Windows.Forms.UserControl
{
A val1 = new B();
A val2 = new C();
.....
this.add(val1);
this.add(val2);
}
Compilation Error because val1/val2 cannot be converted to
UserControl. As far as I know a Interface cannot inherit from a class,
but only extend another inteface. So which Interface can I use so
"this.add(val1)" works??

Thanks a lot,
Langi
Sep 22 '06 #1
1 1450

"Matthias Langbein" <ma***************@web.dewrote in message
news:p8********************************@4ax.com...
Hi all,
how do I solve this problem:

Interface A
{...}

Class B : System.Windows.Forms.UserControl, A
{...}

ClassC : System.Windows.Forms.UserControl, A
{...}

Class D : System.Windows.Forms.UserControl
{
A val1 = new B();
A val2 = new C();
....
this.add(val1);
this.add(val2);
}
Compilation Error because val1/val2 cannot be converted to
UserControl. As far as I know a Interface cannot inherit from a class,
but only extend another inteface. So which Interface can I use so
"this.add(val1)" works??

Thanks a lot,
Langi
try:

this.add((System.Windows.Forms.UserControl) val1);
this.add((System.Windows.Forms.UserControl) val2);

hth,
Mythran
Sep 22 '06 #2

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

Similar topics

0
2271
by: Mark Johnson | last post by:
Sometimes Controls that have been added to a GroupBox do not show up. What I am doing : 1) I am not using the designer, but create all the Controls per hand: groupBoxProdukt_01 = new...
3
2627
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
3
9503
by: gemel | last post by:
Interface definitions do no not contain implementation, only signtures. That is there real purpose. Here thow we have an Inteface which does not have any implementation code but it has to be...
4
2077
by: Bass Pro | last post by:
Hi, I am creating textbox, radiobuttonlist and checkboxlist dynamically depending on data from a table. It is a questionnaire. I add the control on a Panel control during the 1st load_page event....
7
2454
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
8
1196
by: Marius Horak | last post by:
I've never used Interface and never will. But now I have to make major modifications to a large system where almost all classes are based on some kind of Interface. Hundreds of classes. When I...
8
3559
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
9
1646
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I have noticed a lot of COM samples that the function AddRef and Release function of COM inteface is not synchronized to make it thread safe when dealing with adding/decreasing...
3
1567
by: devgupta01 | last post by:
How to see methods of class/inteface of library if i m using console. Please give an example. thnx
0
7202
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
7280
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
7462
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
4673
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
3167
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
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
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...

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.