使用Windows窗体一个TableLayoutPanel。我分别使用RowStyles和ColumnStyles为一个与sizetype为自动调整大小和百分比。我需要找出一个特定的控制放在一个单元格的绝对高度和宽度。
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 and width of a cell in which a particular control is placed.
TableLayoutPanelCellPosition pos = tableLayoutPanel1.GetCellPosition(button1); int height = (int)tableLayoutPanel1.RowStyles[pos.Row].Height; int width = (int)tableLayoutPanel1.ColumnStyles[pos.Column].Width;
以上,我得到高度为0 RowStyle是为一个与sizetype为自动调整大小。 同样地,我越来越为33.33。 ColumnStyle被设置为一个与sizetype的百分比和大小= 33.33。
Above, I am getting height as 0. RowStyle is with SizeType as AutoSize. Similarly, I am getting as 33.33. ColumnStyle is set with SizeType as Percent and Size = 33.33.
我需要绝对尺寸为单元的像素。
I need to get absolute size in pixels for the cell.
推荐答案对于一些奇怪的原因,微软决定从智能感知隐藏这些功能。
For some odd reason, Microsoft decided to hide those functions from intellisense.
这应该是写:
TableLayoutPanelCellPosition pos = tableLayoutPanel1.GetCellPosition(button1); int width = tableLayoutPanel1.GetColumnWidths()[pos.Column]; int height = tableLayoutPanel1.GetRowHeights()[pos.Row];更多推荐
获取的高度和宽度的TableLayoutPanel单元格的Windows窗体
发布评论