C# Change ListView Item's/Row's height

前端 未结 6 1392
轻奢々
轻奢々 2020-12-08 20:43

I want to change the Item\'s/Row\'s height in listview.

I searched every where and I figured that in order to change the height I need to use LBS_OWNERDRAWFIXE

6条回答
  •  北海茫月
    2020-12-08 21:17

    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.

    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.

    This screen shot shows 32-pixel rows and the word wrapping that is possible because of the extra space:

    enter image description here

    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.

提交回复
热议问题