Thread: radioButton

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

    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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
    if (radioButton1 == true)
    {
             System.MessageBox.Show("radioButton1is pressed");
    }
    something like this should compile...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Here is code checked in C#
    Code:
                if (this.radioButton1.Checked == true)
                {
                    System.Windows.Forms.MessageBox.Show("selected");
                }
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    385
    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, 06:46 PM
  2. Radiobutton text to string
    By Elk in forum C# Programming
    Replies: 3
    Last Post: 11-19-2007, 09:31 AM
  3. radiobutton click event
    By SuperNewbie in forum C# Programming
    Replies: 3
    Last Post: 07-15-2002, 12:49 AM