Ok the problem seems to be a little bit more complicated than I thought at
first sight.
Solution, what to do when removing a row:
- decrement tableLayoutPane l.RowCount
- remove rowstyle: tableLayoutPane l.RowStyles.Rem oveAt(...)
- remove corresponding controls of removed row in tabelLayoutPane l.Controls
- change RowCounter of controls that come after the removed row
Explanation of last action:
tableLayout.Get Row('control'), where 'control' is a control belonging to a
row that comes after the remove row, will give you his old rowIndex!
For that you need to set the new rowIndex for all controls belonging to a
row that's coming after a removed row.
My code:
for (int counter = controlsCounter ; counter <
ux_tlpCostCente rs.Controls.Cou nt; counter++)
{
ux_tlpCostCente rs.SetRow(ux_tl pCostCenters.Co ntrols[counter],
ux_tlpCostCente rs.GetRow(ux_tl pCostCenters.Co ntrols[counter]) - 1);
}
Over here the integer 'controlsCounte r' is the beginindex of the first
control in my tableLayoutPane l.Controls that needs a new RowIndex.
This should really help now ;-)
"avanti" wrote:
Hi,
I am trying to delete rows from a TableLayoutPane l at Runtime. I tried
editing the RowStyles collection but doesn't do what I want it to. I
have a table with 10 rows. I want to delete rows 2 to 10 at runtime,
keeping the first row unchanged.
Can this be done?
Thanks,
Avanti Ketkar