-
August 29th, 2013, 05:23 AM
#1
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);
-
August 29th, 2013, 07:07 AM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|