构造函数中的代码如下,运行之后为什么不能显示全部的label标签,只显示了一个,好像是第一个(位置为120,150的那一个)。
InitializeComponent();
ArrayList labelList=new ArrayList();
Label label=new Label();
label.Location = new Point(120, 150);
labelList.Add(label);
label.Location = new Point(138, 150);
labelList.Add(label);
label.Location = new Point(156, 150);
labelList.Add(label);
label.Location = new Point(174, 150);
labelList.Add(label);
label.Location = new Point(174, 132);
labelList.Add(label);
label.Location = new Point(174, 114);
labelList.Add(label);
label.Location = new Point(174, 96);
labelList.Add(label);
label.Location = new Point(156, 96);
labelList.Add(label);
label.Location = new Point(138, 96);
labelList.Add(label);
label.Location = new Point(120, 96);
labelList.Add(label);
label.Location = new Point(120, 114);
labelList.Add(label);
label.Location = new Point(120, 132);
labelList.Add(label);
for (int i = 0; i < labelList.Count;i++ )
{
Label lab=(Label)labelList[i];
lab.BackColor = Color.Blue;
lab.Size = new Size(16, 16);
lab.Text = "";
panel1.Controls.Add(lab);
}
InitializeComponent();
ArrayList labelList=new ArrayList();
Label label=new Label();
label.Location = new Point(120, 150);
labelList.Add(label);
label.Location = new Point(138, 150);
labelList.Add(label);
label.Location = new Point(156, 150);
labelList.Add(label);
label.Location = new Point(174, 150);
labelList.Add(label);
label.Location = new Point(174, 132);
labelList.Add(label);
label.Location = new Point(174, 114);
labelList.Add(label);
label.Location = new Point(174, 96);
labelList.Add(label);
label.Location = new Point(156, 96);
labelList.Add(label);
label.Location = new Point(138, 96);
labelList.Add(label);
label.Location = new Point(120, 96);
labelList.Add(label);
label.Location = new Point(120, 114);
labelList.Add(label);
label.Location = new Point(120, 132);
labelList.Add(label);
for (int i = 0; i < labelList.Count;i++ )
{
Label lab=(Label)labelList[i];
lab.BackColor = Color.Blue;
lab.Size = new Size(16, 16);
lab.Text = "";
panel1.Controls.Add(lab);
}
解决方案 »
- C#编程中的66个好习惯,你有多少个?
- [急]父控件Size小于子控件时,子控件如何在父控件之上叠加完整显示
- asp.net2.0自定义类的问题
- 初学者连接mssql数据库的问题
- 如何检测 操作系统的 语言版本?比如英文,简体中文还是繁体中文?
- udp通讯有点不懂
- C# Oracle10g 不装客户端的配置问题
- ado.net+oracle,能否同时返回多个数据集?
- Dev TreeList (C#)已经获取到某个节点的所有子节点,如何把他们加载到另一个treelist中啊,也就是单击目录树在另一个地方显示他的子节点。
- 为什么我加入TreeView后,运行时显示网页上有错误???
- C#winform这题的效果如何实现?
- .net用AJAX怎样做到无刷新删除啊,
label.Location = new Point(120, 150);
labelList.Add(label);
label=new Label();
label.Location = new Point(138, 150);
labelList.Add(label);
label=new Label();
label.Location = new Point(156, 150);
labelList.Add(label);
label=new Label();
label.Location = new Point(174, 150);
...你一共只有一个label