473,322 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 1139
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
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
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
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
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
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
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
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
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
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
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.