在Windows窗体中使用TableLayoutPanel。我正在将RowTypes和ColumnStyles与SizeType分别用作AutoSize和Percent。我需要找出放置特定控件的单元格的绝对高度和宽度。
TableLayoutPanelCellPosition pos = tableLayoutPanel1.GetCellPosition(button1);
int height = (int)tableLayoutPanel1.RowStyles[pos.Row].Height;
int width = (int)tableLayoutPanel1.ColumnStyles[pos.Column].Width;
上面,我的高度为0。RowStyle的SizeType为AutoSize。
同样,我的评分为33.33。使用SizeType作为Percent和Size = 33.33设置ColumnStyle。
我需要获取像素的绝对大小(以像素为单位)。
最佳答案
出于某种奇怪的原因,微软决定将这些功能隐藏在智能感知中。
这应按书面形式进行:
TableLayoutPanelCellPosition pos = tableLayoutPanel1.GetCellPosition(button1);
int width = tableLayoutPanel1.GetColumnWidths()[pos.Column];
int height = tableLayoutPanel1.GetRowHeights()[pos.Row];
关于c# - 获取Windows窗体中TableLayoutPanel单元格的高度和宽度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13725721/