TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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.?
Reply
Answers (
1
)
Excel - print titles on bottom of page using c#.
How Do I: Move a ListBoxA to ListBoxB