Results 1 to 5 of 5

Thread: [RESOLVED] [2.0] radio button which event when the user clicks on it?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    Resolved [RESOLVED] [2.0] radio button which event when the user clicks on it?

    I am having 2 radio buttons on my windows form (C#). when the user clicks on a radio button I want some code to run.

    In which event of the radio button I should write the code?

    I tried in Checkedchanged event of the radio button, whenever the user clicks on the other radio button, this event gets triggered. I want the code to be executed only when the user clicks on the radio button and not when the user checks another radio button.

    thanks
    nath

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2.0] radio button which event when the user clicks on it?

    Hmm... "Click" maybe?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    Re: [2.0] radio button which event when the user clicks on it?

    I tried putting code in the "Click" event of the radio button and it doesn't work.

    private void rdoOnlyBooks_Click(object sender, EventArgs e)
    {

    }

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] radio button which event when the user clicks on it?

    The CheckChanged event is raised whenever the Checked property changes, either from True to False (unchecked) or from False to True (checked). All you have to do is test the current value of the Checked property to know whether the RadioButton is being checked or unchecked. If it is being checked and you didn't do it yourself in code then it's a fair bet that the user just clicked the RadioButton.
    Code:
    private void radioButton1_CheckedChanged(object sender, EventArgs e)
    {
        if (this.radioButton1.Checked)
        {
            // The user just clicked the RadioButton.
        }
    }
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2.0] radio button which event when the user clicks on it?

    Sorry, I got my radio buttons and checkboxes muddled up

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