1
Reply

how can i write code for radio buttons in visual c#.net?

deepankar

deepankar

16y
14.6k
0
Reply

    Initialize two radio buttons:'Yes' & 'No' in the windows form:

    private System.Windows.Forms.RadioButton rdbtnYes;

    private System.Windows.Forms.RadioButton rdbtnNo;

    Next when you double click on either of two radio buttons you will see the below code will appear in vs 2003 editor:

    private void rdbtnYes_CheckedChanged(object sender, EventArgs e)

    {

    if( rdbtnYes.Checked == true)

    {

    MessageBox.Show("Yes"); // Will show if you check the "Yes" radio button

    }

    }

    private void rdbtnNo_CheckedChanged(object sender, EventArgs e)

    {

    if( rdbtnNo.Checked == true)

    {

    MessageBox.Show("No"); // Will show if you check the "No" radio button

    }

    }

    that's all.happy coding