I have two radiobutton in Status.cs
panels are in class GetDataEmp.cs. GetDataEmp.cs contain two panel(panel1,panel2)one above(overlapped) the other.Panel2 is shown ,Panel 1 is hidden behind panel2.
if i click radiobutton1,panel 1 should be visible
and if i click radiobutton2,panel 2 should be visible
Now what i am doing is ,
in Status.cs
private void radiobutton1 _CheckedChanged(object sender, EventArgs e)
{
Panel panel2 = getpanel.getPanelNonProd();
Panel panel1 = getpanel.getPanelProd();
panel2.Visible = false;
panel1.Visible = true;
}
private void radiobutton2_CheckedChanged(object sender, EventArgs e)
{
Panel panel2 = getpanel.getPanelNonProd();
Panel panel1 = getpanel.getPanelProd();
panel2.Visible = true;
panel1.Visible = false;
}
Initially in design panel2 is visible.And it doesnot change on clicking radiobutton 1 or 2
What should be my approach here..>
Depending upon radiobutton clicked,panel should be visible
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.
DMR Santosh14 pointsPosted Jun 29, 2010, 3:12 AM EDT
Kriti41 pointsPosted Jun 29, 2010, 3:55 AM EDT
Its that,I want to make panel1 visible when i click radiobutton1 and panel2 when i click radiobutton2.(both panel are overlapped in GetDataEmp.cs class
Since panel are in differnt class so i have created a method to retreive the panel in Status.cs class.Once its retreived i have made it visible or invisible depending upon the choices..But thats not working for me..
I hope it makes sense..
Areeb Quazi78 pointsPosted Jun 29, 2010, 3:58 AM EDT
If you are doing panel2 visible true and panel2 visible false on
page load then keep these line inside if(!IsPostback) and
check autopostback property true for radio button
Kriti41 pointsPosted Jun 29, 2010, 5:59 AM EDT
System.Windows.Forms application
Areeb13 pointsPosted Jun 30, 2010, 12:35 AM EDT
private void radiobutton1 _CheckedChanged(object sender, EventArgs e)
{
if (radiobutton1.Checked)
{
Panel panel2 = getpanel.getPanelNonProd();
Panel panel1 = getpanel.getPanelProd();
panel2.Visible = false;
panel1.Visible = true;
}
}
private void radiobutton2_CheckedChanged(object sender, EventArgs e)
{
if (radiobutton2.Checked)
{
Panel panel2 = getpanel.getPanelNonProd();
Panel panel1 = getpanel.getPanelProd();
panel2.Visible = true;
panel1.Visible = false;
}
}