Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I dynamically add buttons on form1 when I press a button. When I press a button on form2, the buttons on form1 must be deleted. How can I do this?
Posted
Updated 18-Nov-10 2:56am
v2

I would get form1 the subscribe to the button click event of form2, either direct or via a custom event of form2. Then in form1 message handler remove the buttons you want.

I presume both forms are modeless
 
Share this answer
 
v2
You can subscribe to the Form2 button event in Form1, and just react to it. Since most controls in a form are private by default, you'll probably have to make the button public.

Alternatively, you can post a custom (public) event in Form2 that Form 1 can subscribe to, and fire that event with the appropriate action has happened in Form2.
 
Share this answer
 
v2

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