Winforms - Empty Form

Birol KORKMAZ 1 Reputation point
2022-07-21T08:03:14.583+00:00

Hello I have a problem i don't know if it is a huge one but i am looking for solutions.

I was making a winforms application. Somehow i did something and the Form looks empty like when you create a new form.

I have the designs and the code but the form is blank.

The last thing i did somehow i entered the designer.cs and Changed the name of a textbox after that form went blank. I tried to give its name back but the form is still blank.

How can i solve this problem? Any ideas?

Developer technologies | Windows Forms
Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Reza Aghaei 4,986 Reputation points MVP Volunteer Moderator
    2023-03-19T19:55:06.7033333+00:00

    You should not edit the designer.cs file manually and there's a comment in code about it:

    /// <summary>  
    ///  Required method for Designer support - do not modify  
    ///  the contents of this method with the code editor.  
    /// </summary>  
    

    Assuming your form is calles Form1, if you have a correct build for the application, and if the content of Form1.designer.cs are still there, then the only thing that you need to do is making sure that there's a constructor like this in Form1.cs:

    public Form1()  
    {  
        InitializeComponent();  
    }  
    

    In some rare cases, you may need close all designer windows, then close Visual Studio, delete bin and obj folders, open the solution and rebuild it again. then open designers.

    You should also use a source control system like git which is integrated with Visual Studio, then in case of such events, you can easily discard changes or restore the working instance of the form.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.