8

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.

//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);
9
  • What errors do you get ? Can you post it. Commented Jan 29, 2014 at 14:50
  • 3
    What line is the error on? Commented Jan 29, 2014 at 14:51
  • 1
    Are you sure you are getting error on these lines ? double click on the error and specify the line you are getting that error Commented Jan 29, 2014 at 14:51
  • 2
    Do you have a TextBox control named Text? Commented Jan 29, 2014 at 14:51
  • 1
    You have textbox named Name, rename it to txtName in designer and your code should be good Commented Jan 29, 2014 at 14:53

2 Answers 2

22

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I solved my problem sir. Thanks! As you have said, there is a textbox named Name so it has conflicts. Thanks for answering! :)
7

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.