473,327 Members | 2,118 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,327 software developers and data experts.

C# Windows Form Inheritance Quesiton

Hi,

In my ASP.Net 1.1, C#, I have two windows forms, one is frmContactPerson,
another is frmContactAddress.
These two forms has many same Controls, except in one GroupBox they have
different TextBoxes showing different data from datatable ContactPerson and
ContactAddress respectively.
Now come my question: How am I gonna apply the "Inheritance" concept in
that situation?
Any help will be appreciated.

Jason
Nov 17 '05 #1
4 2133
What do you want to do? Your post does not really make that clear. Do you
want to create one form that inherits from both forms? Do you want to reuse
the current controls?

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:um**************@TK2MSFTNGP15.phx.gbl...
Hi,

In my ASP.Net 1.1, C#, I have two windows forms, one is frmContactPerson,
another is frmContactAddress.
These two forms has many same Controls, except in one GroupBox they have
different TextBoxes showing different data from datatable ContactPerson
and ContactAddress respectively.
Now come my question: How am I gonna apply the "Inheritance" concept in
that situation?
Any help will be appreciated.

Jason

Nov 17 '05 #2
Thanks Peter.
I'm trying to apply the INHERITANCE concept for saving my coding time.
I would like to reuse the current controls, if possible.
"Peter Rilling" <pe***@nospam.rilling.net> ¼¶¼g©ó¶l¥ó·s»D:e3*************@TK2MSFTNGP15.phx.gb l...
What do you want to do? Your post does not really make that clear. Do
you want to create one form that inherits from both forms? Do you want to
reuse the current controls?

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:um**************@TK2MSFTNGP15.phx.gbl...
Hi,

In my ASP.Net 1.1, C#, I have two windows forms, one is frmContactPerson,
another is frmContactAddress.
These two forms has many same Controls, except in one GroupBox they have
different TextBoxes showing different data from datatable ContactPerson
and ContactAddress respectively.
Now come my question: How am I gonna apply the "Inheritance" concept in
that situation?
Any help will be appreciated.

Jason


Nov 17 '05 #3
The is really the purpose of usercontrols. Try to move those controls (and
the code logic) into a user control. Or is a usercontrol out of the
question given the current design of the application which might result in a
lot of work?

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Thanks Peter.
I'm trying to apply the INHERITANCE concept for saving my coding time.
I would like to reuse the current controls, if possible.
"Peter Rilling" <pe***@nospam.rilling.net>
¼¶¼g©ó¶l¥ó·s»D:e3*************@TK2MSFTNGP15.phx.gb l...
What do you want to do? Your post does not really make that clear. Do
you want to create one form that inherits from both forms? Do you want
to reuse the current controls?

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:um**************@TK2MSFTNGP15.phx.gbl...
Hi,

In my ASP.Net 1.1, C#, I have two windows forms, one is
frmContactPerson, another is frmContactAddress.
These two forms has many same Controls, except in one GroupBox they have
different TextBoxes showing different data from datatable ContactPerson
and ContactAddress respectively.
Now come my question: How am I gonna apply the "Inheritance" concept in
that situation?
Any help will be appreciated.

Jason



Nov 17 '05 #4
On Wed, 12 Oct 2005 14:51:16 +0800, "Jason Huang"
<Ja************@hotmail.com> wrote in
<um**************@TK2MSFTNGP15.phx.gbl>:
In my ASP.Net 1.1, C#, I have two windows forms, one is frmContactPerson,
another is frmContactAddress.
These two forms has many same Controls, except in one GroupBox they have
different TextBoxes showing different data from datatable ContactPerson and
ContactAddress respectively.
Now come my question: How am I gonna apply the "Inheritance" concept in
that situation?


1. Create a form frmContactBase that contains all of the common
controls and code. If you have any controls or code that need to be
accessed by the derived forms, make them protected instead of private.

2. Remove the common controls and code from frmContactAddress and
frmContactPerson.

3. Modify frmContactAddress and frmContactPerson to inherit from
frmContactBase instead of System.Windows.Forms.Form.

One thing to be wary of is that the form designer has some odd
interactions with data-bound controls, datasets, etc. If you need to
populate anything in your Load event handler or constructor, put it
inside an if statement like this:

if (false == this.DesignMode)
{
// Load data
}
--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research
Nov 17 '05 #5

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

Similar topics

1
by: KK | last post by:
Windows Forms Inheritance, Incomplete? I was playing around with Windows Forms and found out this Forms Inheritance feature. The moment I saw that, I felt this can be used effectively if the...
7
by: Evan Kontos | last post by:
I am using the window.open function to open a small window and I am using GET to get values back from that window. I want to be able to open another from the second window but I get an error...
5
by: Eric Chong | last post by:
I created a Windows Service in C# that requires to get passed command arguments like a Console App. I noticed that there is an option "Start parameters" text box in the property of a Windows...
8
by: KraftDiner | last post by:
I have a base class called Shape And then classes like Circle, Square, Triangle etc, that inherit from Shape: My quesiton is can a method of the Shape class call a method in Circle, or Square...
1
by: Max Harvey | last post by:
Hi, I made up a nice little form which had its own sub form in it. I made a litle VB code so that when I pressed a button it would move form the form (frmConference) to the subform...
4
by: Alan T | last post by:
How do I create a form inherited from an existing form in the same project ?
23
by: Chukkalove | last post by:
Im sorry, I dont know the correct description for a hierarchy of parent and child forms. I have a main form that opens a child form modally. This child form in turn opens it's own child form...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
9
by: Scott Stark | last post by:
Hello, I'm *just* delving into Windows forms-based programming without the benefit of any books, etc. I have a background in light ASP.NET work, so forgive me if this is a really basic question...
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
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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.