Winform 窗体设计器 无法识别重复成员变量声明的问题

时间:2023-02-05 15:42:39

打开窗体设计视图出现如下错误:

Winform 窗体设计器 无法识别重复成员变量声明的问题

查看后台代码:

   ColumnHeader colHead;
colHead = new ColumnHeader();
colHead.Text = "Ch";
colHead.Width = ;
this.ChList.Columns.Add(colHead); colHead = new ColumnHeader();
colHead.Text = "ChType";
colHead.Width = ;
this.ChList.Columns.Add(colHead); colHead = new ColumnHeader();
colHead.Text = "Status";
colHead.Width = ;
this.ChList.Columns.Add(colHead); colHead = new ColumnHeader();
colHead.Text = "CallerId";
colHead.Width = ;
this.ChList.Columns.Add(colHead); colHead = new ColumnHeader();
colHead.Text = "CalleeId";
colHead.Width = ;
this.ChList.Columns.Add(colHead);
//
colHead = new ColumnHeader();
colHead.Text = "DTMFBuffer";
colHead.Width = ;
this.ChList.Columns.Add(colHead);

发现设计器不能识别相同变量的声明不同的实例。

将每个ColumnHeader 都声明一次 解决问题