Greetings. On the form there is a TableLayoutPanel , in the cells are buttons. The button in the properties has a Cell field that defines its row and column in tableLayout . enter image description here

But I can't find how to access this Cell from code? I want to dynamically change the row / column of an item.

  • one
    See the methods SetCellPosition , GetCellPosition , SetRow , GetRow , SetColumn , GetColumn . - Alexander Petrov
  • Thanks, figured out using the setCellPosition method. - Nik
  • Please reply with sample code. - andreycha
  • @andreycha designed. - Nik

1 answer 1

To change the position of an element (button, caption, or any other) in tableLayoutPanel , you can use the SetCellPosition method:

 tablelayoutpanel1.SetCellPosition(element, new TableLayoutPanelCellPosition(column, row)); 

It should be mentioned that in the same cell of the table there can be only one element; when you try to place an object in an already occupied cell, the cells will shift.