如何获取ListView的头部高度 - C#头部、高度、ListView

2023-09-03 01:55:16 作者:莪昰伱读不懂的心酸

可以sombody告诉我怎么去列表视图的头部高度。

Can sombody tell me how to get the header height of a list view.

感谢

推荐答案

这可能是一个有点哈克,但你可以这样做:

This might be a little bit hacky but you can do:

listView.Items[0].Bounds.Top

这只会工作,如果只有一个在列表中的项目。所以,你可能要暂时补充之一,当你第一次创建列表,并保持高度的价值。

This will only work if there is only one item in the list. So you might want to temporarily add one when you first create the list and keep the height value.

否则,您可以随时使用:

Else, you can always use:

listView.TopItem.Bounds.Top

为了使测试在任何时刻,但你仍然在列表中至少需要一个项目。

To make the test at any moment, but you still need at least one item in the list.