问题描述
我想改变项目的/列的列表视图中的高度。
I want to change the Item's/Row's height in listview.
我搜查每一个地方,我想通了,为了改变高度,我需要使用 LBS_OWNERDRAWFIXED
或 MeasureItem
或者类似的东西。
I searched every where and I figured that in order to change the height I need to use LBS_OWNERDRAWFIXED
or MeasureItem
or something like that.
问题是,我不知道到底该怎么做,以及如何使用它..
谁能帮我呢?
The problem is that I dont know exactly what to do and how to use it..
Can anyone help me with it?
编辑:
因为我用的是SmallImageList真正的我不能使用ImageList的黑客,我需要不同的线高度从ImageList中的图像大小。
I cant use the ImageList hack because I am using the SmallImageList for real and I need different line height from the ImageList images size.
谢谢!
推荐答案
可以使用 SmallImageList
招做 - 你就必须要小心。 - 围绕一个标准的.NET的一个开源包装的ListView
- 使用该招成功实施的rowHeight
属性。
It can be done using the SmallImageList
trick -- you just have to be careful. ObjectListView -- an open source wrapper around a standard .NET ListView
-- uses that trick to successfully implement a RowHeight
property.
如果你想32像素的每一行,分配一个的ImageList
是16×32(宽×高),然后位置的每个图像中的垂直中点32像素高度。
If you want 32 pixels for each row, allocate an ImageList
that is 16x32 (width x height), and then position each of your images in the vertical middle of the 32-pixel height.
此屏幕截图显示32像素行和自动换行,这是因为额外的空间可能:
This screen shot shows 32-pixel rows and the word wrapping that is possible because of the extra space:
ObjectListView
做这一切为你工作。事实上,如果你试图用一个ListView做任何事,你应该认真看使用 ObjectListView
来代替。这使得很多困难的事情琐碎,和一些不可能的事情(例如重叠,虚拟列表组)可能的(例如,通过列类型,自定义工具提示排序)。
ObjectListView
does all this work for you. In fact, if you are trying to do anything with a ListView, you should seriously looked at using an ObjectListView
instead. It makes many difficult things (e.g. sorting by column type, custom tooltips) trivial, and several impossible things (e.g. overlays, groups on virtual lists) possible.
这篇关于C#更改ListView项的/行的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!