473,395 Members | 1,341 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 Inheritanc Problem in .net

Hy Friends,

Using visual inheritance feature of .net, I've inherited a Form (Form2) from an existing form (Form1) of the same assembly or project. It's perfectly inherited and when I run the application it's executing fine. But when I open the inherited form (Form2) in designer, It throws an exception in form_load event of Parent Form (Form1) as code block in form_load event requires some data which will be available only when application runs. Due to this problem, I can not make changes in Inherited Form (Form2) using designer.

Now, my question is that, why It's going to call Form_Load event of Parent Form (Form1) while opening Inherited Form (Form2) in the designer. Is there any solution to that problem.

Please help.

Thanks.
Jul 18 '07 #1
4 1112
TRScheel
638 Expert 512MB
Hy Friends,

Using visual inheritance feature of .net, I've inherited a Form (Form2) from an existing form (Form1) of the same assembly or project. It's perfectly inherited and when I run the application it's executing fine. But when I open the inherited form (Form2) in designer, It throws an exception in form_load event of Parent Form (Form1) as code block in form_load event requires some data which will be available only when application runs. Due to this problem, I can not make changes in Inherited Form (Form2) using designer.

Now, my question is that, why It's going to call Form_Load event of Parent Form (Form1) while opening Inherited Form (Form2) in the designer. Is there any solution to that problem.

Please help.

Thanks.

Could you show code?

My guess is, though, that something like this is what you will find for form2's code:

Expand|Select|Wrap|Line Numbers
  1. public class Form2 : Form1
  2. {
  3.      public Form2() : base()
  4.      {
  5.      }
  6. }
  7.  
Though, i dont see why that wouldnt allow you to see Form2 in designer. I have never tried this though...
Jul 18 '07 #2
Could you show code?
here is the code:

Form1 Code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show("Parent Form Load Event");
}
}

Form 2 Code:
public partial class Form2 : Form1
{
public Form2()
{
InitializeComponent();
}
}


Now form_load event of Form1 is triggered when I open Form2 in designer and shows message box. But I don't want this behavior and I don't want form_load event to be triggered while opening designer.
Jul 19 '07 #3
RoninZA
78
Hi All,

The problem is that, because you are inheriting Form2 from Form1, when you open Form2 in the designer, the Form_Load event of Form1 will fire (and I assume events like Form_Activate, etc). I don't know if this is intentional or a bug, but I know there must be a couple of ways to get around it, but I think the easiest way would be to put error handling around the offending code (which you should actually already have done).

Hope this helps!
Jul 19 '07 #4
TRScheel
638 Expert 512MB
You have to remove Form_Load from the Load event handler of the Form1 instance created under Form2.
Jul 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: angelag | last post by:
I am currently taking a college course in Visual Basic.Net and I am a beginner. I bought Visual Studio.Net 2003 to do my homework at home. I built my first project and e-mailed it to myself at...
6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
0
by: gerd | last post by:
Hello, I want to port an MFC Application from Visual Studio 6 MFC application to Visual C++ 2005 express edition beta. While building i get following error: ------ Build started: Project:...
1
by: Daniel A. Thomas | last post by:
License required Maybe you don't have this but have one of the products that qualifies for the upgrade such as ... Visual Studio .NET 2003 Professional Visual Studio .NET 2003 Professional...
3
by: Edwin Smith | last post by:
I have a 2 form project in VS2005 that now hangs whenever I try to do anything with the second form. This seems to have started when I added some SQL tables from a Pervasive v.9 database using the...
2
by: Cramer | last post by:
So, what is the relationship between Visual Studio and Visual Web Developer. I find a lot of documentation on MSDN that presents Visual Web Developer as it's own stand-alone product (which I'd...
0
jwwicks
by: jwwicks | last post by:
Introduction This tutorial describes how to use Visual Studio to create a new C++ program, compile/run a program, resume work on an existing program and debug a program. It is aimed at the...
3
by: Johnson | last post by:
I'm not sure if this is an IIS 5.1 issue or ASP.NET issue, or Visual Studio 2008 issue -- thus posting to 3 groups. Please don't be offended. The problem I'm encountering is that Visual Studio...
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:
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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
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...
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.