Tech Support > Microsoft Windows > Development Resources > ListView selection not visible
ListView selection not visible
Posted by r_z_aret@pen_fact.com on October 9th, 2003


I am using C/C++ and straight Win32 (no MFC, ATL, ...). I have a
ListView. When I try to select an item programmatically, the
selection is not visible. I use the following code:
ListView_SetItemState( hWnd, nChoice, LVIS_SELECTED |
LVIS_FOCUSED, 0x000F );
ASSERT( ListView_GetItemState( hWnd, nChoice, LVIS_SELECTED )
Neither ASSERT triggers. Also, when I change a column width (by
dragging a header, not programmaticaly), the selection becomes
visible. So I think the code above is correct, but not sufficient.

I'm using VC 6 and Windows NT 4 SP 5. Also, the only styles I specify
for the ListView are LVS_REPORT | LVS_SINGLESEL. I've tried not using
LVS_SINGLESEL. I develop primarily for Windows CE, so any solution
must work under it (them?), but I don't think that will be a real
issue in this case.

Thank you.
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com

Posted by Ali R. on October 9th, 2003


That's because the item is selected.
Add this style to your list view LVS_SHOWSELALWAYS

Ali R.

<r_z_aret@pen_fact.com> wrote in message
news:3f8585b1.15382749@nntp.theworld.com...


Posted by r_z_aret@pen_fact.com on October 9th, 2003


On Thu, 09 Oct 2003 17:50:16 GMT, "Ali R." <nospam@mail.com> wrote:

Sure enough, I _had_ missed the obvious. Thank you.

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com


Similar Posts