The documentation of the ListView control (using WinApi) seem to lack some basic information, here are some questions I couldn't seem to find a solutin to:
On most apps, when you double-click the border to the right of a column, the column resizes to some default width. I would have guessed that this width is specified by LVCOLUMN.cxDefault or cxIdeal, but it doesn't seem to do it. What am I missing?
When you click a certain column to sort the list according to, a little arrow indicating the direction of the sort appears on top of it. How do I make it appear? BTW, does anybody know which sorting algorithm ListView uses?
When in report view, any way to select a whole row instead of just the first item? (It's just a visual thing, functionally it's identical)
Any way to insert multiple items at once?
-
- It's calculated based on the rendered width of each item in that column.
- The arrow is a custom image set by your program. If you don't set an image (by associating an image list with the header and then specifying an image for each header item by index), then you don't get one. I don't know what the sort algorithm is, but the item comparison algorithm is whatever you want it to be - you must specify a callback.
- Yes - set the
LVS_EX_FULLROWSELECT
extended style on the control - No. But you can turn off redraw while adding multiple items.
My best recommendation for you if you're new to working with the ListView control is to read the numerous articles on CodeProject. Even if you're not working with MFC (as many of the articles are) the concepts still apply - just translate calls to the equivalent PlatformSDK macros.
Meat : Thanks for the answers. 1. Obvious. Don't know how I didn't notice that. 2. Seems like an overkill. Windows seems to have some default graphics for that arrow. Plus, it's different for each visual style, how should I match that standart with a custom image? 3. Works like magic. 4. Would look into thatShog9 : If you can afford to drop pre-XP compatibility, you can use the v6 common controls and get some extra goodies (like, themes, groups, selected column indicator, etc). I haven't worked with this enough to know if you get sort images with that however.Meat : Any hint where can I look into it?Meat : Found it .Meat : "The sorting algorithm is whatever you want it to be - you must specify a callback.". Not entirly true. The callback only compares individual items, it doesn't suuply any sorting logic.Shog9 : Sorry, thought you were talking about the comparison function for some reason... Couldn't tell you what algorithm is used for sorting internally. -
Ok, here's the answer to the second problem: http://www.winapizone.net/tutorials/winapi/listview/columnsortimage.php
0 comments:
Post a Comment