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

C# Windows Form Inheritance Quesiton

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


P: n/a
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

P: n/a
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> 撰寫於郵件新聞: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

P: n/a
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>
撰寫於郵件新聞: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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.