CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2013
    Posts
    77

    Selection of full row via program

    I am doing a win32 application using List view control,I used extended style LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT.My application demands for force selection of row(ie,Searching for an item,if it found select that item via program)I tryed with both LVM_SETITEMSTATEas well as ListView_SetItemState,But iam not getting as selected
    First code using macro
    Code:
    itemNo=Search(lvItem.pszText)//Search the item and returned the item index,working fine
    MessageBox()//Item already exist
    ListView_SetItemState(hWnd, itemNo, LVIS_SELECTED | LVIS_FOCUSED, 
    0x000f); //fails
    using LVM_SETITEMSTATE

    Code:
    itemNo=Search(lvItem.pszText)//Search the item and returned the item index,working fine
    MessageBox()//Item already exist
    lvItem.iItem=itemNo;
    lvItem.mask=LVIF_STATE;
    lvItem.state=LVIS_SELECTED;
    lvItem.stateMask=0x00f;
    SendMessage(hWnd,LVM_SETITEMSTATE,itemNo,(LPARAM)&lvItem);

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Selection of full row via program

    things I can think off...

    1) the messagebox is throwing things off.
    Note that the selected style isn't visible unless the control has the focus, a messagebox would typically change focus.

    tip: you can make the selection visible anyway by using the LVS_SHOWSELALWAYS listview style.

    2) are you sure hWnd is the listview window handle ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured