代码改变世界

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

2014-03-05 16:03  CodeCy  阅读(496)  评论(0编辑  收藏  举报

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

查看后台代码:

   ColumnHeader colHead;
            colHead = new ColumnHeader();
            colHead.Text = "Ch";
            colHead.Width = 30;
            this.ChList.Columns.Add(colHead);

            colHead = new ColumnHeader();
            colHead.Text = "ChType";
            colHead.Width = 99;
            this.ChList.Columns.Add(colHead);

            colHead = new ColumnHeader();
            colHead.Text = "Status";
            colHead.Width = 78;
            this.ChList.Columns.Add(colHead);


            colHead = new ColumnHeader();
            colHead.Text = "CallerId";
            colHead.Width = 80;
            this.ChList.Columns.Add(colHead);

            colHead = new ColumnHeader();
            colHead.Text = "CalleeId";
            colHead.Width = 80;
            this.ChList.Columns.Add(colHead);
            //
            colHead = new ColumnHeader();
            colHead.Text = "DTMFBuffer";
            colHead.Width = 80;
            this.ChList.Columns.Add(colHead);

 

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

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