C# 创建窗口句柄时出错。 在线等待大神......!!!!!!
private TableLayoutPanel _lvwTable = null;
public void BindTable()//每1秒调用这方法刷新一次
{//加过程序锁还是一样
DisposeControls(_lvwTable);
_lvwTable.Controls.Clear();
int useState, j = 0;
Label lbl = null;
for (int i = 0; i < 30; i++)
{
lbl = new Label();
lbl.Width = 120;
lbl.Height = 120;
lbl.Cursor = Cursors.Hand;
lbl.Margin = new Padding(3, 3, 3, 3);
lbl.ContextMenuStrip = this.cmsLvwItem;
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.Font = new Font("微软雅黑", 12);
lbl.Image = _StateColor[1];
_lvwTable.Controls.Add(lbl, (j % _Column), (j / _Column));
//刷新3分钟左右就报错乐/ 创建窗口句柄时出错。
}
}
private void DisposeControls(Control cParent)
{
foreach (Control c in cParent.Controls)
{
c.Dispose();
}
}
c#
句柄
动态生成控件