ListView Columns Name屬性為空

来源:互联网 发布:笔记本支架哪个好 知乎 编辑:程序博客网 时间:2024/05/18 03:57

这里写图片描述
ListView設定列,并給列的Name屬性賦值,
但是是要用ListView1.Colomns[0].Name時,卻發現這個值為空

到 .Designer.cs文件里去看卻發現 只給Text屬性賦值Name屬性沒有賦值,設計時填寫的a只作為一個變量,並不是Name的值

      this.a.Text = "列1";            //             // b            //                    this.b.Text = "列2";            //             // c            //                  this.c.Text = "列3";            //             // d            //                    this.d.Text = "列4";

發現這個問題就好辦了,已是手動給Name賦值,這樣ListView1.Colomns[0].Name就能取到值了

            this.a.Name = "a";            this.a.Text = "列1";            //             // b            //             this.b.Name = "b";            this.b.Text = "列2";            //             // c            //             this.c.Name = "c";            this.c.Text = "列3";            //             // d            //             this.d.Name = "d";            this.d.Text = "列4";
原创粉丝点击