473,813 Members | 3,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Windows Form Inheritance Quesiton

Hi,

In my ASP.Net 1.1, C#, I have two windows forms, one is frmContactPerso n,
another is frmContactAddre ss.
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 "Inheritanc e" concept in
that situation?
Any help will be appreciated.

Jason
Nov 17 '05 #1
4 2155
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******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

In my ASP.Net 1.1, C#, I have two windows forms, one is frmContactPerso n,
another is frmContactAddre ss.
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 "Inheritanc e" 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.r illing.net> ¼¶¼g©ó¶l¥ó·s»D: e3************* @TK2MSFTNGP15.p hx.gbl...
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******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

In my ASP.Net 1.1, C#, I have two windows forms, one is frmContactPerso n,
another is frmContactAddre ss.
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 "Inheritanc e" 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******** ********@TK2MSF TNGP12.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.r illing.net>
¼¶¼g©ó¶l¥ó·s»D: e3************* @TK2MSFTNGP15.p hx.gbl...
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******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

In my ASP.Net 1.1, C#, I have two windows forms, one is
frmContactPerso n, another is frmContactAddre ss.
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 "Inheritanc e" 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 frmContactPerso n,
another is frmContactAddre ss.
These two forms has many same Controls, except in one GroupBox they have
different TextBoxes showing different data from datatable ContactPerson and
ContactAddre ss respectively.
Now come my question: How am I gonna apply the "Inheritanc e" 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 frmContactAddre ss and
frmContactPerso n.

3. Modify frmContactAddre ss and frmContactPerso n 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
3755
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 application contains couople of forms which have a consistant look and also shares SOME similar functionality between the forms.
7
3204
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 message when I try to do another window.open. Any suggestions are welcomed. Evan Kontos | EKontos@comtekcadd.com 27 Whitehall St. | 3rd Floor | New York, NY 10004 Tel 212.480.8166 | Fax 212.480.8167 | Personal Fax 786.513.0295...
5
7196
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 Service in MMC. Is there any way to get arguments using this option? If possible, what framework method should I use to get an arguement? Thanks in advance. Eric
8
1579
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 etc...?
1
3061
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 (frmBookingBookingBased), start a new record, and copy some values form the form into some fields in the subform, and then leave the cursor sitting (in focus) at the begining of the subform.
4
304
by: Alan T | last post by:
How do I create a form inherited from an existing form in the same project ?
23
2742
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 modally. I also have a separate thread running that monitors a card reader. If the user removes the card then the thread calls back the main form to tell it that the card was pulled. The main form should then close down any children leaving the main...
12
11119
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. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
9
1807
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 related to Windows GUI. I've created a "Form1.vb" file in my project, added a menustrip, etc. When a user clicks on a menu item, how do I get it to show a new form in the same window?
0
9734
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10669
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10408
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10426
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10141
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7686
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5707
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3886
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.