Why can’t I see Form1.Cs

Asked

Viewed 404 times

0

I created a tableLayoutPanel and later wanted to put a Panel in each cell of tableLayoutPanel.

I made the following code and when I compile, it works.

Panel[,] panels = new Panel[tableLayoutPanel1.RowCount+1, tableLayoutPanel1.ColumnCount+1];
for (int i = 1; i <= tableLayoutPanel1.RowCount; i++) {
    columns = 0;
    for (int j = 1; j <= tableLayoutPanel1.ColumnCount; j++) {
        panels[i, j] = new Panel() {
            BackColor = Color.AliceBlue,
            Margin = new Padding(0),
        };
        tableLayoutPanel1.Controls.Add(panels[i, j], i - 1, j - 1);
        columns++;
        counter++;
    }
    rows++;
}
Controls.Add(tableLayoutPanel1);

Why am I unable to access Design when I have this code? The error that appears is the following:

"The designer cannot process the code at line 445 (...) The code Within the method 'Initializecomponent' is generated by the designer and should not be Manually modified. Please remove any changes and Try Opening the designer Again."

  • Welcome to SOPT. @João, could [Edit] your question and clarify the part "I can no longer access Design", got confused. Thank you.

  • 1

    I have already edited. I cannot see the "visual" part of the program. The Form1.Cs[Design file].

  • @Joãolopes where did you put this code? Which method and in which file?

  • I put the code in Form1.Designer.Cs. Ok, I got it... Here’s the problem... I can’t put the code here

1 answer

0

You’re coding in the file .design.cs instead of coding in the Behind code, the design files are generated and maintained by Visual Studio and you shouldn’t modify them.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.