这个我会:
本示例以编程方式创建一组 Windows 窗体单选按钮,并将其 Text 属性设置为字符串数组中的值。示例
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]);
}
}
编译代码
本示例需要: 一个含有名为 button1 的 Button 控件的 Windows 窗体。将 button1 的 Click 事件处理程序设置为 button1_Click。
本示例以编程方式创建一组 Windows 窗体单选按钮,并将其 Text 属性设置为字符串数组中的值。示例
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]);
}
}
编译代码
本示例需要: 一个含有名为 button1 的 Button 控件的 Windows 窗体。将 button1 的 Click 事件处理程序设置为 button1_Click。
解决方案 »
- 新手学c#.求老鸟意见建议
- C#创建XML文件问题,在线等
- 請問錯誤當前上下文中不存在名稱“ScriptManager”如何解決?
- asp.net中可以用nunitasp进行测试,请问winform程序的界面测试如何有没有什么可以进行
- .net + Oracle 的 OracleCommand.ExecuteNonQuery 问题
- 页面中如何装载mht
- 求解决方案
- 子窗口最大化的问题!
- 发生了异常“Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException”?
- IIS打开网站出错
- 请问谁用好的压力测试软件测试socket架构的软件???
- 指针问题
private TextBox[] TextBoxArray = new TextBox[]
{
TextBox1,
TextBox2,
TextBox3
}
//这是一个TextBox数组
只能用集合。它的Controls属性。