|
-
Feb 29th, 2004, 01:02 PM
#1
Thread Starter
Lively Member
Events
Hi, I have 4 radio buttons and i have assigned one method to handle them all(checked event). but i cannot know wich one was pressed or not. i was looking for something like:
private void opDrinks_CheckedChanged(object sender, System.EventArgs e)
{
sender.source = opDrink1
}
, but it doesnt work..
Last edited by iScanning; Feb 29th, 2004 at 01:13 PM.
-
Feb 29th, 2004, 01:24 PM
#2
Frenzied Member
If you are going to do it like that then you have to wire the events manually.
Wire up your events
Code:
rdoBeer.CheckedChanged += new EventHandler(opDrinks_CheckedChanged);
rdoSoda.CheckedChanged += new EventHandler(opDrinks_CheckedChanged);
Test for what you want
Code:
private void opDrinks_CheckedChanged(object sender, EventArgs e)
{
string drink = ((RadioButton)sender).Text;
switch(drink)
{
case "Beer"
{
MessageBox.Show("Beer");
break;
}
case "Soda" :
{
MessageBox.Show("Soda");
break;
}
}
}
-
Feb 29th, 2004, 02:14 PM
#3
Frenzied Member
you could use the tag as well and possible the name. You have to set a tag first though. n/m I don't think you could use the name
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|