Why can not I see Form1.cs

0

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

I made the following code and when compiling 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 do I stop being able to access Design when I have this code? The error that appears is as follows:

  

"The designer can not process the code at 445 (...) The code   within the method 'InitializeComponent' is generated by the designer   and should not be handled. Please remove any changes and try   opening the designer again. "

    
asked by anonymous 20.01.2016 / 13:14

1 answer

0

You are coding in the file .design.cs instead of code in code behind, the design files are generated and maintained by Visual Studio and you should not modify them.

    
20.01.2016 / 16:56