如果ListView列名为Name,则得到CS0029无法将类型'string'隐式转换为'System.Windows.Forms.ColumnHeader'

时间:2019-11-05 04:06:00

标签: .net-core

如果我的.Net Core 3.0 ListView控件中有一个名为Name的列,则会出现以下错误

Error   CS0029  Cannot implicitly convert type 'string' to 'System.Windows.Forms.ColumnHeader'

如果我重命名列,则错误得到解决

Form1.Designer.cs显示以下内容。

CS5009

如果我将该列重命名为Column1,那么就没有错误

        this.Column1.Name = "Column1";
        this.Column1.Text = "Name";
        this.Column1.Width = 500;
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(800, 450);
        this.Controls.Add(this.listView1);
        this.Controls.Add(this.button1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);

0 个答案:

没有答案