Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
HI Guys.

I have two form.
In Form1 i have a button(btnExit) with this code: application.exit();
In Form2(it's Inherited Form of Form1), i want to delete btnExit,but it's impossible.

Can I ask if someone have an idea to how can i fix this error?
i deleted the btnExit in Form1 but its in Form2 yet.!!!!
Posted
Updated 3-Dec-12 23:47pm
v2

1 solution

You cannot delete the button from form two. You can only do it in Form1's designer view.

However, you can do something like this in the Form2's constructor.

C#
this.btnExit.Visible = false;


P.S.:
By the way, why do you need to do this? If your Form1 contains items not necessary for it's children, there must be a problem with design. Parent classes should only have things that are common to all its children.
 
Share this answer
 
Comments
siasalar 4-Dec-12 6:00am    
yes youre right.
i have a Exitbutton in Form1(parnet form) now i dont want to have it, i want to delete it in all forms.but how?
siasalar 4-Dec-12 6:02am    
i delete it in form1 designer view but it didnt delete in form2 its exist yet.
krumia 4-Dec-12 6:03am    
Rebuild your project and try to open the forms in designer view again.
siasalar 4-Dec-12 6:06am    
wooooooooooow , i wrote about 15000 line code, write it again????
krumia 4-Dec-12 6:11am    
Didn't tell you to rewrite. "Rebuild" as in this: http://nickstips.files.wordpress.com/2010/10/rebuild.png?w=780

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900