473,395 Members | 1,666 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,395 software developers and data experts.

Visual inheritance not working

JD
Hi
I had 2 forms inheriting from a base one. It all worked nicely to start off
with. Don't know what I did next (did some code in the base form), because
now the VS IDE doesn't want to open either of the child forms.

It complains about "ConnectionString property has not been initialized".
I'm tryig to build a 3 tier application so there is no DB connections on
mypresentation layer. But then, I just started C# so am probably missing
something obvious. The same error also displays when I try to create a new
form from the base.

Another thing to note is that the inherited forms work when I execute the
code. It is just in the IDE where I get the problem. I'll send code to
anyone who volunteers to help.

Thanks

Nov 16 '05 #1
6 1641
A couple things to know about form inheritance and the designer ...

1) The designer will instantiate your base form. This means the base form's
constructor will be called. (I think this is true... it's all very
compicated and I may not have it quite right...) If you use the derived form
in code (but do not instantiate the base form), then only the derived form's
constructor will be called. So possibly you have something that needs to be
initialized in order for the base form to be shown, but you're only
initializing it in the derived form?

2) There seems to be a weird restriction on the designer that if you have a
certain name that gets inherited, you can not name anything else in your
project by the same name, or by a name that differs only in casing... That
is, if you have a form with a derived control MyControl, you will have a
conflict (according to the designer) if a different form (not derived from
the same base) has something named myControl. There is no reason in C# these
should conflict, but the designer can't deal with it. (At least, mine
can't.)

3) This is something I've run across, not specifically about form
inheritance, and I see it as a bug, so maybe in some other version it's
fixed, but does seem to be a desiger issue...
If you have a property defined in an interface with only a "get", but define
a class that has a "get" and a "set" on that property, it will compile (and
I think should be fine, since interface only defines a subset of the
functions in a class.) However, if you have a component or control that
implents the property as read/write, the designer says you have conflicting
definitions (I guess it sees read only property as fundamentally different
from read/write property.)

Hope this helps,
Rachel

"JD" <JD@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
Hi
I had 2 forms inheriting from a base one. It all worked nicely to start
off
with. Don't know what I did next (did some code in the base form),
because
now the VS IDE doesn't want to open either of the child forms.

It complains about "ConnectionString property has not been initialized".
I'm tryig to build a 3 tier application so there is no DB connections on
mypresentation layer. But then, I just started C# so am probably missing
something obvious. The same error also displays when I try to create a new
form from the base.

Another thing to note is that the inherited forms work when I execute the
code. It is just in the IDE where I get the problem. I'll send code to
anyone who volunteers to help.

Thanks

Nov 16 '05 #2
JD
Thanks to Rachel for the quick response, although I could still not find the
problem. As promised the code was sent to your email address.
Thanks in advance
Nov 16 '05 #3
JD,

Could it be that some data binding you've done on the form relies on a DB
connection at design time to show your data binding options, and is unable
to estalish that?

--Bob

"JD" <JD@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
Hi
I had 2 forms inheriting from a base one. It all worked nicely to start
off
with. Don't know what I did next (did some code in the base form),
because
now the VS IDE doesn't want to open either of the child forms.

It complains about "ConnectionString property has not been initialized".
I'm tryig to build a 3 tier application so there is no DB connections on
mypresentation layer. But then, I just started C# so am probably missing
something obvious. The same error also displays when I try to create a new
form from the base.

Another thing to note is that the inherited forms work when I execute the
code. It is just in the IDE where I get the problem. I'll send code to
anyone who volunteers to help.

Thanks

Nov 16 '05 #4
JdT
I don't think the IDE should be trying to establish DB connections at design
time.

Here is the code that connects to my Business tier - > linking to my Data
Tier.
private void FeeBase_Load(object sender, System.EventArgs e)
{
FeeInfoCollection fic = new FeeInfoCollection();
// Fill the collection from the DB
fic.GetFees();
this.dgFees.DataSource = fic;
}
Nov 16 '05 #5
> .. As promised the code was sent to your email address.
Thanks in advance


Sorry, I can not debug your ap for you. Even if I wanted to, my system does
not support Microsoft Access database. Here are a coupla things you might
try ...

A) Try to find the simplest possible project or solution that will reproduce
your problem. In doing so, you'll probably figure out what it is.

B) You can set breakpoints to debug code in design mode as follows (assuming
you are using VS)...
(1) Open the solution and select the project where the base form
is defined in one instance of VS
(2) Go to Project->Properties->Configuration Properties->Debugging
(a) Set "Debug Mode" to "Program"
(b) Set Start Application to devenv.exe (you may need
to supply path)
(c) Set Command Line Arguments to the *.sln file for your test ap
(can be the same solution you're in, that's fine.)
(3) RightClick on project & choose "Set as Startup Project"

Now when you F5 to debug, A new instance of VS will be started.
You can try adding an inherited form to that project and see if any
breakpoints get hit...

Hope this helps...
-Rachel
Nov 16 '05 #6
JdT
Thanks Rachel & Bob

It did turn out that the inherited forms call the Load event of the Base
form and thus tried to connect to the DB at design time.

I find this a bit weird, but at least the problem is gone. Testing if I'm
in design mode now before calling th eDB connection code.

Cheers
Nov 16 '05 #7

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

Similar topics

20
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
10
by: Gopal Prabhakaran | last post by:
Hi Pls Help me to do Visual Inheritance with ASP.NET -- Thanx Gopal Prabhakaran
6
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
6
by: Phill. W | last post by:
I've created my own form (say, "AppletBase" with some basic controls (mainly GroupBoxes) on it. Now, I'm trying to inherit from this to create other applications. Class AppletBase Inherits...
6
by: Bart Schelkens | last post by:
Hi, i've created a base-form from which all the forms in my application need to inherit. This works just fine. I've put some buttons on my base-form. They are displayed correctly, only if my...
2
by: Ray Cassick \(Home\) | last post by:
Since I got such good feedback from the Xml comments question I will ask this of the group as well. Is VS.NET 2005 handling the visual inheritance problems centered around controls and forms...
6
by: Ranginald | last post by:
I have a page, default.aspx.cs that instantiates a label, label1 and adds some properties to the label: Label Label1 = new Label(); this.Controls.Add(Label1); Label1.BackColor =...
4
by: MikeB | last post by:
I've been all over the net with this question, I hope I've finally found a group where I can ask about Visual Basic 2005. I'm at uni and we're working with Visual Basic 2005. I have some books, ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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
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...

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.