문제

I have a TableLayoutPanel control that has a row with x columns. Each cell inside has a Panel control.
I want to exchange a column x with column y in run time.

How can I do this?

Once again, the question was: How to change columns' order in a tablelayoutPanel?

도움이 되었습니까?

해결책

If you have a reference to each Panel control use those and skip the first two lines of the code below (ie. the GetControlFromPosition() function I've used below to get the reference to the Controls) -

Control ctr1 = tableLayoutPanel1.GetControlFromPosition(0, 0);
Control ctr2 = tableLayoutPanel1.GetControlFromPosition(1, 1);

tableLayoutPanel1.SetCellPosition(ctr1, new TableLayoutPanelCellPosition(1, 1));
tableLayoutPanel1.SetCellPosition(ctr2, new TableLayoutPanelCellPosition(0, 0));

Replace the 0's and 1's with Row and Column Index where you want to place the control..

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top