资 源 简 介
C# 基于字符串数组创建一组单选按钮的例子,附上了例子源代码,大家可了解C#字符串数组的简单应用。
以下是例子中的代码,运行后可见如下图所示的图片效果:
//基于字符串数组创建一组单选按钮
string[] MyArray = new string[4];
MyArray[0] = "渝北区";
MyArray[1] = "巴南区";
MyArray[2] = "长寿区";
MyArray[3] = "南岸区";
RadioButton[] MyRadioButtons =new RadioButton[4];
for (int i = 0; i < 4; ++i)
{
MyRadioButtons[i] = new RadioButton();
MyRadioButtons[i].Text = MyArray[i];
MyRadioButtons[i].Location = new System.Drawing.Point(
10, 20 + i * 20);
this.groupBox1.Controls.Add(MyRadioButtons[i]);
}
this.groupBox1.Text = "请评选全市卫生城区:";