Skip to content

Depending upon radiobutton clicked,panel should be visible

Kriti

Asked Jun 29, 2010, 1:38 AM EDT5 answers
Share
LinkedInX
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..>

5 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • DMR Santosh
    0
    Hi this is dmr santosh, first tell me this you have created some methods under panels right??? you want to run those method when you click on the radio button ??
    0
  • 0
    No its not that i want to call a method..
    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..
    0
  • 0
    Kirti,

    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
    0
  • 0
    cant use that coz we are using
    System.Windows.Forms application
    0
  • 0
    ok Kriti try this one

    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;
        }
    }
    0