基于字符串数组创建一组单选按钮

private void button1_Click(object sender, System.EventArgs e)
{
    string[] stringArray = new string[3];

    stringArray[0] = "Yes";
    stringArray[1] = "No";
    stringArray[2] = "Maybe";

    System.Windows.Forms.RadioButton[] radioButtons =
        new System.Windows.Forms.RadioButton[3];

    for (int i = 0; i < 3; ++i)
    {
        radioButtons[i] = new RadioButton();
        radioButtons[i].Text = stringArray[i];
        radioButtons[i].Location = new System.Drawing.Point(
            10, 10 + i * 20);
        this.Controls.Add(radioButtons[i]);
    }
}
posted on 2010-05-20 10:49  记住昨天,迎接明天  阅读(230)  评论(0编辑  收藏  举报