ListView auto size to show all items

后端 未结 2 1731
我寻月下人不归
我寻月下人不归 2021-01-22 01:42

What I want to create is a list view that will resize itself in order to show all items. Normally I would use AutoSize, but this won\'t work here. Any other options how can I ma

相关标签:
2条回答
  • 2021-01-22 01:58

    "AutoSize" property is not supported for the "ListView" control. As @JohnArien mentioned, you will have to programmatically re-size your list view control's size according to the number of items available. But be warned that this may not be a good idea in terms of visual appeal of the Form. Your form design might look ugly if you change the size in run time. More over these types of controls are expected to expand their client area within the given size with the help of scroll bars. I would strongly suggest you to reconsider this option.

    0 讨论(0)
  • 2021-01-22 02:05

    You will have to manually calculate your desired height and set it as items are added/removed.

    Detecting item addition or removal isn't directly supported - so you'll either need to create your own Add/Remove Item calls for clients to call, or handle LVN_INSERTIEM type messages from WndProc.

    Auto-sizing controls are usually trickier to use - as you have to track Min/Max sizes, allow room on the owner, and usually add to an awkward usability point for users. Only do something like this if typical solutions (i.e. scroll bars) truly can't work for your need.

    0 讨论(0)
提交回复
热议问题