获取的高度和宽度的TableLayoutPanel单元格的Windows窗体

编程入门 行业动态 更新时间:2024-10-10 13:16:55
本文介绍了获取的高度和宽度的TableLayoutPanel单元格的Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用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窗体

本文发布于:2023-11-23 01:05:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619552.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   宽度   单元格   高度   TableLayoutPanel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!