473,569 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problems with inheritance???

Hi..

I have a standard windows app in C#. The project contains a two forms and one class that i have created. I want both of the forms to inherit from the class but i am getting an error reading "type in interface list is not an interface"??? i am not sure how to fix the problem. Is an interface (form) unable to inherit from a non interface type??

any help appreciated
Nov 15 '05 #1
2 3922
Darryn,
this is a little confusing because a "form" is not an interface, it is a class.
Perhaps with some code example we can get a better insight into what your goal really is.
You can't get the properties of a Windows Form class by having a class derive from another class that doesn't inherit itself from System.Windows. Forms.Form.
--Peter
"Darryn Ross" <da****@datawav e.com.au> wrote in message news:Ow******** ******@TK2MSFTN GP11.phx.gbl...
Hi..

I have a standard windows app in C#. The project contains a two forms and one class that i have created. I want both of the forms to inherit from the class but i am getting an error reading "type in interface list is not an interface"??? i am not sure how to fix the problem. Is an interface (form) unable to inherit from a non interface type??

any help appreciated
Nov 15 '05 #2
"Darryn Ross" <da****@datawav e.com.au> wrote in message news:Ow******** ******@TK2MSFTN GP11.phx.gbl...
The project contains a two forms and one class that i have created.
I want both of the forms to inherit from the class but i am getting an error


Form is a class, not an interface. Therefore, the form (which inherits
from System.Windows. Forms.Form) has already used up its one
permitted inheritance, and cannot simultaneously inherit from the
other class you have created.

C# only supports single inheritance, not multiple inheritance like C++.

The workaround is to aggregate this other class, such that your form
still inherits from form, but your form subclass must:

1. Contain an instance of the other class you've created in the
constructor as a member field.

2. Expose the methods and properties of the class you've created.

Aggregating the class, I'll call it T, in lieu of inheriting from it, would
look something like this:

public class F : Form
{
private T impl;
public F( ) { impl = new T( ); }
public int Foo( int x) { return impl.Foo( x); }
}

Normally, its desirable to make the methods and properties of the
aggregated class to be defined in an interface. Then anyplace where
you might ordinarily expect an instance of this class, you would use a
reference to this interface instead. The form class, instead of inheriting
from two classes, could inherit from one class and implement the interface
of the aggregated object (which supplies the actual implementation of
the interface and is delegated to by the form).

In a more interface or type-driven manner such as this, not having multiple
inheritance is not a problem.
Derek Harmon
Nov 15 '05 #3

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

Similar topics

2
3082
by: Matt | last post by:
I have created an MDI child form that I am using as a base form in a VB.Net MDI application. The base MDI child form has a series of menu options on it. I then use this form to create other MDI child forms (using inheritance). The problem is that the derived MDI child form's menu options don't seem to have inherited the functionality from...
13
3269
by: John Perks and Sarah Mount | last post by:
Trying to create the "lopsided diamond" inheritance below: >>> class B(object):pass >>> class D1(B):pass >>> class D2(D1):pass >>> class D(D1, D2):pass Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: Error when calling the metaclass bases Cannot create a consistent method resolution
4
2745
by: Alex Hunsley | last post by:
I've seen a few discussion about the use of 'super' in Python, including the opinion that 'super' should only be used to solve inheritance diamond problem. (And that a constructor that wants to call the superclass methods should just call them by name and forget about super.) What is people's opinion on this? Does it make any sense?
3
2636
by: Roman S. Golubin1709176985 | last post by:
All how do you do! Who what cases uses for C# programming? I have an experience with Microsoft Visio several days. He has a problem with interface inheritance... óan who that other advise? Thank in advance! -- WBR, Roman S. Golubin
5
1654
by: Mac via DotNetMonster.com | last post by:
Hi all, I have a creating a my own tabpage class (MyTabPage) which inherits the .Net TabPage class. In the relevant event I want to loop through the collection of TabPages and then when I find the TabPage I am after I want to cast this to MyTabPage so that I can access the properties that I have added to this class. When I try to do...
1
1416
by: George Durzi | last post by:
I'm converting a c# web application to support page inheritance so that I can really change the look and feel of my application by only modifying the ..cs that my pages inherit from. The only recurring problem I'm having is that none of my HtmlInputFile controls are working after the conversion. The page inheritance setup is pure vanilla,...
1
1273
by: bill | last post by:
What's up with inheritance in code behind? Is it reliable, or should I skip it and forget about using inheritance in web forms until they get it right? I'm using VB.NET 2005 I have a web form named wfBase.aspx. In the code behind I have Partial Public Class wfBase
2
2082
by: beseecher | last post by:
Hi, In my research in the javascript language I have encountered problems with implementing prototype inheritance while preserving private methods functioning properly. Here is an example: function A(){ var _this = this; this.a = 10;
3
1447
by: djboyse | last post by:
Hey, I'm kind of new to C++ and having some problems with inheritance. I've tried looking everywhere for some help, but I'm not too sure what to ask so please any input will be greatly appreciated. (Please let me no if I start talking rubbish too) Basically I have my base class with 3 functions and two global integers. I also have a derived...
0
7605
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...
0
7917
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. ...
0
8118
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...
1
7665
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...
0
7962
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 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...
1
5501
isladogs
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...
0
3651
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
933
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...

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.