GroupBoxes are like any other control: they have a Visible property.
First some comments on your design. You have two GroupBoxes, only one of which should be displayed at a time. You need to have a control that can have only one of two states active at a time. The control that provides exclusivity is the RadioButton, not the Button. I would place two RadioButtons, named, say product_RB with a tag of product and category_RB with a tag of category, into a third GroupBox, named, say, controls_GB. I will describe the use of the tags below. Set the CheckChanged event handler for both RadioButtons to, say, RB_CheckChanged.
I would declare two boolean variables, named, say, product_active and category_active to track which GroupBox is active. Initialize product_active to true and category_active to false.
The tags product and category are used in the event handler RB_CheckChanged to detect which RadioButton was clicked. Actually, when one of the RadioButtons is clicked, the event handler is invoked twice: once for the RadioButton being "unclicked" and once for the RadioButton being clicked.
Lastly, I do not know if you are overlapping your GroupBoxes but that is a useful way to keep from using valuable real estate.
using System;
using System.Windows.Forms;
namespace GroupBoxVisible
{
public partial class GroupBoxVisible : Form
{
bool category_active = false;
bool product_active = true;
void initialize_GUI ( )
{
control_GB.Visible = true;
category_GB.Visible = category_active;
product_GB.Visible = product_active;
}
public GroupBoxVisible ( )
{
InitializeComponent ( );
initialize_GUI ( );
}
void RB_CheckedChanged ( object sender,
EventArgs e )
{
bool is_checked = false;
RadioButton radio_button = null;
string tag = String.Empty;
radio_button = ( RadioButton ) sender;
is_checked = radio_button.Checked;
if ( radio_button.Tag == null )
{
throw new ApplicationException (
@"A tag is not assigned to the RadioButton" );
}
tag = radio_button.Tag.ToString ( ).ToLower ( ).Trim ( );
if ( tag.Length <= 0 )
{
throw new ApplicationException (
@"A zero length tag is assigned to the " +
@"RadioButton" );
}
switch ( tag )
{
case @"product":
product_active = is_checked;
break;
case @"category":
category_active = is_checked;
break;
default:
throw new ApplicationException (
String.Format (
@"{0} is an unrecognized tag", tag ) );
}
initialize_GUI ( );
}
}
}
Hope that helps.