Click here to Skip to main content
15,036,145 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm working on a project that uses a tableLayoutPanel. I can't seem to figure what I'm doing wrong when I insert a new Row it's not increasing the rowIndex of the subsequent rows. Example:

TableLayoutPanel tlp = new TableLayoutPanel();
tlp.GrowStyle = TableLayoutPanelGrowStyle.AddRows;
tlp.AutoSize = true;
tlp.ColumnCount = 2;
tlp.ColumnStyles.Add(new ColumnStyle());
tlp.ColumnStyles.Add(new ColumnStyle());
tlp.RowCount = 3;;
tlp.RowStyles.Add(new RowStyle());
tlp.RowStyles.Add(new RowStyle());
tlp.RowStyles.Add(new RowStyle());

tlp.Controls.Add(new Panel(),0,0);
tlp.Controls.Add(new Panel(),0,1);
tlp.Controls.Add(new Panel(),1,0);
tlp.Controls.Add(new Panel(),1,1);

// code...
// code...
// etc...

// Here's where I'm having the issue
// when i create a new row and insert it
// between two existing rows, the following
// rows index does reflect that they now 
// have a new row location
tlp.RowCount++;
tlp.RowStyles.Insert(1, new RowStyle());
tlp.Controls.Add(new Panel(), 0, 1);


So when I create a new row and insert this row between two existing row the following row's index does not increase!

What am I missing here?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900