A user can click on row 5 or cursor down to row 5 of a ListView, but how can I set the current row to 5(any number actually) under program control? I have been able to get the current row number by intercepting the LVN_ITEMCHANGED message. I use the data in the columns to populate other fields on my form. When the program starts up, it fills the LV and then needs to select the first row so that the fields and the current row are showing the same data. I am ashamed to admit that I resorted to giving the LV focus and then sending it a down arrow to it to get it to highlight the first row.:mad: Thanking you in advance, Onyx
Posted on 2001-02-15 18:48:00 by Onyx
You need to use LVM_SETITEMSTATE:


invoke SendMessage,hList,LVM_SETITEMSTATE,0,ADDR LVI ;0 indicates the first row
Posted on 2001-02-15 21:16:00 by martin
That has the appearance of working but.... If the user leaves the listview on the second row (index 1) and I set it, using your example (thanks by the way), to row 5 then row 5 is indeed selected onscreen. But when the user hits the down arrow, row three is selected. It appears that your solution sets the row "selected" but does not the modify the LV's index.
Posted on 2001-02-16 18:08:00 by Onyx
To make the row selected and focused, simply do the following: .data? LVI LVITEM .code mov LVI.state,LVIS_SELECTED or LVIS_FOCUSED mov LVI.stateMask,LVIS_SELECTED or LVIS_FOCUSED invoke SendMessage,hList,LVM_SETITEMSTATE,0,ADDR LVI
Posted on 2001-02-16 20:15:00 by martin