473,509 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How? Object is a form and inherits as well

Hi All

I am just learning C# and .NET please be patient with me :-) I would
be very interested in how you approach the problem below:

I have a form (collects username and password information) and these
are presented as public properties. I also like this form to be
another object from a library of controls (call it ControlX) so I can
use that base functionality. (give it to a control container which
keeps a collection of them etc).

There is no multiple inheritance - so I can only inherit from the
system Form class or ControlX. ControlX does not seem to offer any
interfaces. Is it possible to inherit from ControlX and somehow
transparently imbed the form functionality in the class so that the
clase is a ControlX and is a Form? (or vice versa)

I suppose I could make a ControlX class and then have it internally
create and manage an instance of a separate Form class to display its
contents when asked. But then I'd have two separate clases maintain,
load and transfer data between. Is this really the way you would do
it? Is there a better way?

All opinions and advice gratefully received.

Cheers
-R
Jul 21 '05 #1
1 1148
Based on the limited information of what you are trying to accomplish, I
would say your last suggestion is probably the best way to do it. It is
called "extension through composition", which is often preferred over
"extension through inheritance".
RubiconXing wrote:
Hi All

I am just learning C# and .NET please be patient with me :-) I would
be very interested in how you approach the problem below:

I have a form (collects username and password information) and these
are presented as public properties. I also like this form to be
another object from a library of controls (call it ControlX) so I can
use that base functionality. (give it to a control container which
keeps a collection of them etc).

There is no multiple inheritance - so I can only inherit from the
system Form class or ControlX. ControlX does not seem to offer any
interfaces. Is it possible to inherit from ControlX and somehow
transparently imbed the form functionality in the class so that the
clase is a ControlX and is a Form? (or vice versa)

I suppose I could make a ControlX class and then have it internally
create and manage an instance of a separate Form class to display its
contents when asked. But then I'd have two separate clases maintain,
load and transfer data between. Is this really the way you would do
it? Is there a better way?

All opinions and advice gratefully received.

Cheers
-R

Jul 21 '05 #2

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

Similar topics

0
2670
by: monkey king | last post by:
I have a given dll file(PDFCreator.dll) - probably generated by VC++. I want to use its method(PDFCreator()) in dotNet environment. It works well in WindiowsApplication, but bad in WebApplication...
2
2433
by: A. Nonymous | last post by:
Hello, I am trying to set up a panel that appears on a page that prompts a user to enter in a note. This panel object is initially invisable and appears when the user clicks on a button. ...
11
2196
by: Antony | last post by:
I know this sounds stupid but I am going to carry on anyway. I want to create an interface that implements all methods of a form, plus another one or two. But I need to know if there is an...
14
4003
by: Jan Nielsen | last post by:
Hi In Microsoft Access it is possible to write code like this Sub test() DoCmd.OpenForm "TestForm", acDesign Dim a As Control For Each a In Forms("TestForm").Controls Do stuff Next End Sub
3
2568
by: Anthony Fine | last post by:
Hello All, I have a VB.Net app that needs to send mail. I have created a class for building my e-mail, but keep getting the error (Could not access 'CDO.Message' object.) when trying to send...
8
3966
by: Raterus | last post by:
Hi, I don't even know if this can be done.. Lets say I have two objects, --- Public Class Employee End Class
8
2456
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!!...
15
26212
by: mr.peteryu | last post by:
Hi, Can someone explain the idea behind casting to an interface? For example: -> I have an IInterface that contains a Read() method. -> I have an object "obj" that implements IInterface. ...
1
4861
by: Mike9900 | last post by:
I would like to return an object which inherits an interface. A web service instantiate a class that inherits that interface and returns that object. But I get error when referencing the web...
1
8332
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an...
0
7342
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,...
1
7067
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
7505
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
4729
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
3215
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
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
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.