Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of LVCOLUMN.iSubItem?

I don't understand what is the purpose of LVCOLUMN.iSubItem. This is what MSDN says:

iSubItem

Type: int

Index of subitem associated with the column.

I first thought that it means that when I create a column, I can set an index to the column, for example: 123, and then when I want to insert some data into the column, I just supply the number 123 as an identification to the column.

But it does not work, no matter what indexes I set to the columns, the columns are still numbered 0, 1, 2, 3, ...

like image 303
user4582812 Avatar asked Apr 30 '15 09:04

user4582812


1 Answers

No, LVCOLUMN.iSubItem is numbered sequentially from 0, left to right as you found out. Yes, it certainly looks like it has no purpose since you must always specify the column number to do anything with an LVCOLUMN. So it just gives you back what you already know.

Hard to guess how this happened, other than to note that the common controls were not exactly Microsoft's finest moment. I suspect it might have something to do with the LVS_EX_HEADERDRAGDROP on a listview. That allows the user to re-arrange the columns by dragging them. Now the column index you pass to LVM_GETCOLUMN gets a bit murky, is it supposed to indicate the position or the original index of the column? They went with the latter and used LVM_GETCOLUMNORDERARRAY if you need to know how the user arranged the columns.

Or they simply mirrored LVITEM.iSubItem to keep the structures similar, somewhat likelier perhaps. Don't worry about it.

like image 113
Hans Passant Avatar answered Oct 05 '22 04:10

Hans Passant