无法将类型字符串隐式转换为System.Windows.Forms.DataGridViewTextBoxColumn

时间:2017-06-22 13:50:54

标签: c# asp.net windows

我已尝试过以下解决方案,但仍然给我同样的错误: Cannot implicitly convert type 'string' to 'System.Windows.Forms.TextBox'

以下是我的表单元素代码:

 private void InitializeComponent()
{
         this.Controls.Add(this.splitContainer1);
            this.ImeMode = System.Windows.Forms.ImeMode.On;
            this.Name = "UserForm"; // Here I have a problem while runing the application
            this.Text = "User Log Management";
}

我试图更改Form的名称,但仍无法正常工作。

以下是代码的Snap: Here is the Snap for code 感谢

2 个答案:

答案 0 :(得分:1)

表单中的一个文本框的ID为"名称"。将其重命名为" txtName"并且您的代码应该可以正常工作

答案 1 :(得分:0)

您的表单上有一个TextBox控件,您调用了Name。这导致了冲突。将文本框重命名为不同的文本框。 WinForms开发中的一个常见约定是使用控件前缀(或后缀)。例如txt用于文本框。例如txtName

有关命名的进一步讨论,请参阅here