C# 无法隐式转换类型';字符串';至';System.Windows.Forms.TextBox';

C# 无法隐式转换类型';字符串';至';System.Windows.Forms.TextBox';,c#,C#,我不知道该怎么办,因为错误出现在Form1.Designer.cs中,而且我没有调试该部分程序的经验 //Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(352, 246); this.Contr

我不知道该怎么办,因为错误出现在
Form1.Designer.cs
中,而且我没有调试该部分程序的经验

//Form1
// 
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(352, 246);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Generate Username";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
错误就在这里。Name=“Form1”


我怀疑您创建了一个名为
Name
的控件,该控件与窗口的
Name
属性冲突。只需将控件重命名为其他名称,它就会再次工作。

错误必须来自其他地方,这里没有
文本框。该错误可能是由于将字符串分配给文本框本身而不是将字符串分配给文本框的
Text
属性造成的

例子: 这应该是:

TextBox tb = new TextBox();
tb.Text = "Default text";

否则,您已经创建了一个名为
name
Text
的控件,在这种情况下,您必须将其重命名为
NameTextBox
或其他名称。

会出现什么错误?你能把它贴出来吗。错误在哪一行?你确定这些行上有错误吗?双击该错误并指定您收到该错误的行您有名为Text的TextBox控件吗?您有名为
Name
的TextBox,在designer中将其重命名为
txtName
,您的代码应该是好的。我解决了我的问题,先生。谢谢正如您所说,有一个名为Name的文本框,因此它有冲突。谢谢你的回答!:)
TextBox tb = new TextBox();
tb.Text = "Default text";