Results 1 to 3 of 3

Thread: Events

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    92

    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.

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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;
    			}
    	}				
    }

  3. #3
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    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
  •  



Click Here to Expand Forum to Full Width