• Have Any Question?
  • contact@eitworld.com

csharp.net radiobutton control





    • A radiobutton control is also called an option button.
    • It is very similar to CheckBox control but is it has round shape and you can select only one radiobutton at a time in a group of radio buttons.
    • You can place a radiobutton control on the form by drag and drop it from the toolbox. The radiobutton control looks like as follows:

radiobutton-control

Properties of radiobutton Control

Some of the commonly used properties of radiobutton Control are listed below in the Table:

radiobutton-control

Methods of radiobutton Control

Some of the commonly used methods of radiobutton Control are listed below in the Table:

radiobutton-control

Events of radiobutton Control

Some of the commonly used Events of Radio Control are listed below in the Table:

radiobutton-control

Example

Here is a simple example of radiobutton control. To understand the use of the radiobutton control follows the given steps:

    • Add Two radiobutton controls and a TextBox control on the form from the toolbox.
    • Now double click on radiobutton1 and add the following code in its code-window:
private void radiobutton1_CheckedChanged(object sender, EventArgs e)
{
if (radiobutton1.Checked == true)
{
textBox1.Text = “You clicked at radiobutton1”;
}
}

    • Now double click on radiobutton2 and add the following code in its code-window:
private void radiobutton2_CheckedChanged(object sender, EventArgs e)
{
if (radiobutton2.Checked == true)
{
textBox1.Text = “You clicked at radiobutton2”;
}
}

    • Now run the application using F5 key. This will generate a Form in which first radio button is selected by default so a message appears in the text box.
    • Click on the radiobutton2 . This will show the message changes in the textbox:
radiobutton-control
radiobutton-control


Real Time Web Analytics