This documentation is archived and is not being maintained.

RadioButton.Checked Property

Gets or sets a value indicating whether the control is checked.

[Visual Basic]
Public Property Checked As Boolean
[C#]
public bool Checked {get; set;}
[C++]
public: __property bool get_Checked();
public: __property void set_Checked(bool);
[JScript]
public function get Checked() : Boolean;
public function set Checked(Boolean);

Property Value

true if the check box is checked; otherwise, false.

Example

[Visual Basic, C#, C++] The following example evaluates a ListBox selection and the Checked property of a RadioButton. When a specified item is selected from the list box, the PerformClick method of another RadioButton is called. This code assumes that two RadioButton controls and a ListBox have been instantiated on a form.

[Visual Basic] 
Private Sub ClickMyRadioButton()
    ' If Item1 is selected and radioButton2 
    ' is checked, click radioButton1.
    If (listBox1.Text = "Item1") And radioButton2.Checked Then
        radioButton1.PerformClick()
    End If
End Sub


[C#] 
private void ClickMyRadioButton()
{
   // If Item1 is selected and radioButton2 
   // is checked, click radioButton1.
   if (listBox1.Text == "Item1" && radioButton2.Checked)
   {
      radioButton1.PerformClick();
   }
}


[C++] 
private:
void ClickMyRadioButton() {
   // If Item1 is selected and radioButton2 
   // is checked, click radioButton1.
   if (listBox1->Text->Equals("Item1") && radioButton2->Checked)
   {
      radioButton1->PerformClick();
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

RadioButton Class | RadioButton Members | System.Windows.Forms Namespace

Show: