By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 2,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

Inteface for Controls.Add(???)

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a

"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 discussion thread is closed

Replies have been disabled for this discussion.