Turn off graphical inheritance
-
I have to have form2 inheriting all the methods and variable in form1. but I don't want to have the graphical stuff from form1. how to by pass that? because when i specify form2 inherit from form1 and run the program, it shows on the graphical components of form1 on form2. Im using C# with VS2005 Donkaiser
-
I have to have form2 inheriting all the methods and variable in form1. but I don't want to have the graphical stuff from form1. how to by pass that? because when i specify form2 inherit from form1 and run the program, it shows on the graphical components of form1 on form2. Im using C# with VS2005 Donkaiser
All controls are created in code in C#. The forms designer places the control declarations in the FormName.Designer.cs file, which you can see when you click the [+] next to your class in the Solution Explorer. This file contains the
InitializeComponent
method, which is called by the class constructor.Form2
's constructor callsForm1
's constructor, which callsForm1.InitializeComponent
; thenForm2
's constructor callsForm2.InitializeComponent
. You'll have to come up with a way of stoppingForm1
'sInitializeComponent
being called. I would recommend moving the data manipulation methods and variables out of the Form1 class into a different class, making Form1 and Form2 use that new class, and removing the inheritence link between Form1 and Form2. Stability. What an interesting concept. -- Chris Maunder