Cannot implicitly convert type 'string' to 'System.Windows.Forms.TextBox'

前端 未结 2 1012
不思量自难忘°
不思量自难忘° 2021-01-12 06:51

I don\'t know what to do because the error is in the Form1.Designer.cs and because I have no experience in debugging that part of the program.

/         


        
相关标签:
2条回答
  • 2021-01-12 07:11

    The error is on this.Name = "Form1";

    I suspect you have created a control named Name, which conflicts with the Name property of the window. Just rename the control to something else and it should work again.

    0 讨论(0)
  • 2021-01-12 07:12

    The error must come from somewhere else, there's nothing here with a TextBox. The error is probably caused by assigning a string to a TextBox itself instead of assigning a string to the Text property of the TextBox.

    Example:

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

    This should be:

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

    Otherwise you have created a control with a name like Name or Text, in which case you'll have to rename it to NameTextBox or something.

    0 讨论(0)
提交回复
热议问题