How to select a row fully through program

Aug 29, 2013 at 10:17am
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
1
2
3
4
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
1
2
3
4
5
6
7
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);
Aug 29, 2013 at 11:38am
I had just face the same issue..

You have to set hte extended style using
ListView_SetExtendedListViewStyle(hWnd, LVS_EX_FULLROWSELECT);

As Andy illustrated for me, the 1st parameter in the CreateWindowEx API affects only the window and not the control. So, in order to add any extended style to any control, you need to set it using the corresponding macro. For ListView for example:
ListView_SetExtendedListViewStyle

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775076(v=vs.85).aspx

The link below list all the accepted values of 1st parameter of the CreateWindowEx API:
http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx

You can refer to my case on:
http://www.cplusplus.com/forum/windows/109462/
Aug 30, 2013 at 10:59am
i also need about this Topic... i have same Problem here..
Topic archived. No new replies allowed.