Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 385
Claud Avatar asked Dec 06 '11 22:12

Claud


People also ask

How to make button disappear c#?

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

How do I hide a button in Visual Studio?

Click View > View Textboxes. The two textboxes you added should disappear. To hide a control, simply set it's Visible property to False.

How do you hide the button in Blazor?

To disable a button in Blazor after it is clicked, set the disabled property to true for the button element by binding the property. In the sample, the disabled property of a button element is set to true on button click.


2 Answers

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

like image 76
Dracorat Avatar answered Sep 20 '22 16:09

Dracorat


Yes...

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

like image 42
Ed S. Avatar answered Sep 21 '22 16:09

Ed S.