C#中怎样将四个按钮分别赋值为1、2、3、4

来源:百度知道 编辑:UC知道 时间:2024/06/26 01:48:47

int []arr = new int[]{1,2,3,4};
Button[] btnArray = new Button[4];
for(int i=0;i<btnArray.Length;i++)
{
btnArray[i] = new new Button();
btnArray[i].Text=arr[i].ToString();
......还可以对btnArray[i]的其他属性进行设置
}

List<Button> ButtonList = new List<Button>;//创建一个Button类的链表
for(int i=0;i<4;i++)
{
ButtonList.Add(new Button());
ButtonList[i].Text=i.ToString();
}

属性里改name

是啊,你要讲清楚啊,赋值给?

想要什么要值 是text还是ID?