Get height and width of TableLayoutPanel cell in Windows Forms

后端 未结 2 1828
深忆病人
深忆病人 2020-12-31 04:53

Using a TableLayoutPanel in Windows Forms. I am using RowStyles and ColumnStyles with SizeType as AutoSize and Percent respectively. I need to find out the absolute height a

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 05:24

    For some odd reason, Microsoft decided to hide those functions from intellisense.

    This should work as written:

      TableLayoutPanelCellPosition pos = tableLayoutPanel1.GetCellPosition(button1);
      int width = tableLayoutPanel1.GetColumnWidths()[pos.Column];
      int height = tableLayoutPanel1.GetRowHeights()[pos.Row];
    

提交回复
热议问题