Claud
Claud

Reputation: 1075

How to hide/show buttons c#

I want to be able to make a program. It's a program for a pizza from. I have two buttons on the side (Pizza and subs) When I click the pizza button, i want it to show the rest of the buttons to add a small pizza,medium pizza and large pizza. If i click the subs button however the pizza buttons go away and instead the subs button appear to add subs.. etc

Is there any way to do that?

Upvotes: 5

Views: 72641

Answers (5)

Raj
Raj

Reputation: 11

select button fields and open filds property now select event from top of property windos and then select event as mouse click event and double click on that after that u will able to see in view code mouse click event now write the code.

button1.Visible = true;

Upvotes: 1

Dracorat
Dracorat

Reputation: 1194

To answer your question as asked, you should put all the controls for Pizza in to one GroupBox and the controls for Subs in to another GroupBox. Place both GroupBoxes at the same location and then on the click of the radio button, make one visible and the other not visible.

That said, you should consider the user experience. More intuitive than a form changing based on radio buttons (and even easier to code) would be a TabControl with tabs of "Pizza" and "Subs".

TabControl: http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.aspx

Upvotes: 8

Almo
Almo

Reputation: 15871

You can set NameOfControl.visible = false on any controls you want to disappear.

Setting NameOfControl.visible = true shows them again.

Upvotes: 3

David
David

Reputation: 73594

Just set the Visible property of the buttons to true or false as needed.

Upvotes: 3

Ed Swangren
Ed Swangren

Reputation: 124790

Yes...

Handle the Click event and, in the handler, set the Visible property of your buttons/UserControl/whatever.

Upvotes: 5

Related Questions