Kriti

Kriti

  • NA
  • 60
  • 0

How to access the value of radiobutton ?

May 10 2010 7:52 AM

In my GUI page I have two radio button named Prod and NonProd.
I have two class test and design
In the test class,i have the code as
public
partial class test : SmartPart
{
public test ()
{

InitializeComponent();
radProd.CheckedChanged +=
new EventHandler(Action_CheckedChanged);
radNonProd.CheckedChanged +=
new EventHandler(Action_CheckedChanged);

}
public bool radioProdChecked
{
get { return this.radProd.Checked; }
}
public bool radiononProdChecked
{
get { return this.radNon.Checked; }

}

void Action_CheckedChanged(object sender, EventArgs e)
{
if (radioProdChecked)
{

EmployeePart.Visible =
true;
ManagerPart.Visible =
false;
}
else if (radiononProdChecked)
{

 EmployeePart.Visible = true;
ManagerPart.Visible =
false;


}

}
 
Now in design
I need to get the value of which radiobutton is checked and perform some action
so Design.cs goes as follows
public Design()
{
InitializeComponent();

test t = new test(); //whenevr this calls,it resets all the value and hence the value of radio buttons is always false
if (t.radioChecked==true)
RequestNotVisible();
else if(t.radiononProdChecked==true)
RequestVisible();
}
 
but the problem is that when i run the application at first ,it will be correct.But when in the GUI,I click nonProd radiobutton,It does not display accordingly because still the value of radiononProdChecked comes as false.It happens because constuctor resets all the values.
How can i get the value of radio buttons correctly.?

Answers (1)