0

Controls in TableLayoutPanel get additional properties that are accessible in IDE. One is Row and another is Column, relative to TableLayoutPanel.

How do I get those properties' values by code?

I need to loop through all controls in my TableLayoutPanel and issue instructions based on their relative positions; but when I cast retrieved controls as a specific type, I don't get Row and Column properties.

J0e3gan
  • 8,740
  • 10
  • 53
  • 80
ArtK
  • 1,157
  • 5
  • 17
  • 31
  • You can look at this [link](http://stackoverflow.com/questions/1142873/winforms-tablelayoutpanel-adding-rows-programatically), it may help you to access rows and columns of tablelayout from code – prasy Dec 11 '14 at 16:50
  • To what specific type(s) are you casting the controls in the `TableLayoutPanel`? Some example code that demonstrates the problem you are having would help others to better understand and answer your question. – J0e3gan Dec 11 '14 at 17:26
  • Use the TLP's GetRow() and GetColumn() methods. – Hans Passant Dec 11 '14 at 19:04

1 Answers1

2

You need to do it the other way around. Use TableLayoutPanel.GetCellPosition(Control c) method and pass your control to the method. Assign the return value to TableLayoutPanelCellPosition class variable. That object has Row and Column properties that return integer values.