1
Reply

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

deepankar

deepankar

Apr 24, 2008
14.6k
0

    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

    sudipto chatterjee
    April 24, 2008
    0