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.

Form inheritance
Phill Midwinter
Derek at Potters Clay
Is there something wrong with my IDE
Jassim Rahma
You need to set this to protected (so that the variable/member can be accessed by anybody inheriting from the control.)
You could alternately open up the designer file and change the private declarations onthe form controls to protected. Might be easier to do unless you just plan to do it to a few controls.
Nidonocu
So as I siad in my opening statement, yes you could technically do it say by moving them around to the OnInit and then make sure that your Form2 never called the Form1's onInit do it but you have no guarantee that the Designer is not going to wipe your settings and put what it knows is supposed to go there. You may also run into issues if the 2 controls happen who end up having the same name.
As I recommended you should look at the 2 provided methods that I specified.
marcy
There are probably 2 ways to do this and you can decide whichone is best for you .
Method #1 - Probably the easiest but not the best method
FormA - Move all of your methods here
Form1 inherits from FormA and has all of its regular interface
Form2 inherits from FormA and hgas its own interface
Method #2
Decouple all of your logic and move it into a class that both Form1 and Form2 instantiates from.
This way both Form1 and Form2 can use same methods but not be reliant upon one another.
This method requires the most reworking but in the long run is the best "design" choice.
Hope this helps.
nhaas
Binu Jeesman
Tarey Wolf
Sanjukta
All properties/methods/members are private by default.
public class Form1 { String FullName;
public String MyPlace; }
in Form 2 you have
Form1 frm1 = new Form1();
You can't access FullName because it is not public.
You can however access MyPlace because we specified that it was public.
frm1.MyPlace;
Take a gander here for more information.
Hope this helps.