radioButton

This is a discussion on radioButton within the C# Programming forums, part of the General Programming Boards category; I have put a radiobutton to a Form that I have named radioButton1. As I know a radiobutton can have ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    383

    radioButton

    I have put a radiobutton to a Form that I have named radioButton1.
    As I know a radiobutton can have 2 states, true and false.
    What I wonder here is for this code example that will show a messagebox if radioButton1 is pressed.

    However this does not compile.
    Code:
    if (radioButton1 = true)
    {
             MessageBox::Show("radioButton1is pressed");
    }
    I tried to find these members to radioButton1 but I cant find these members to the radioButton1 class. I do find hundreds of others but not these 2.

    Code:
    radioButton1->GetState()
    radioButton1->IsChecked()

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,456
    Code:
    if (radioButton1 == true)
    {
             System.MessageBox.Show("radioButton1is pressed");
    }
    something like this should compile...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,456
    Here is code checked in C#
    Code:
                if (this.radioButton1.Checked == true)
                {
                    System.Windows.Forms.MessageBox.Show("selected");
                }
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    383
    I think that did it really. I was trying out to make a private class bool variable and inside the radiobutton eventhandler make this variable to evaluate to true or false and then refer to that variable if that variable was true or false. That did also work but kind of "go around". thanks for your solution.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Radio Buttons in a dialog box
    By Swarvy in forum Windows Programming
    Replies: 3
    Last Post: 01-02-2009, 05:46 PM
  2. Radiobutton text to string
    By Elk in forum C# Programming
    Replies: 3
    Last Post: 11-19-2007, 08:31 AM
  3. radiobutton click event
    By SuperNewbie in forum C# Programming
    Replies: 3
    Last Post: 07-15-2002, 12:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21