From: vijay on
Hi

i am taken a dialog based application. on the dialog i placed
CListCtrl.i added 3 cols and 10 row to the list control. the first
column is Checkbox.
On the dialog box i placed two Buttons with captions "Next" and
"Previous". when i run my application, when i Press "Next" Button the
selection mark in the CListCtrl should move to the next row.and when i
press "Previous" the selection mark in the CListCtrl should move to the
previous row.

i am using

nItem=5;
m_ListCtrl.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED,
LVIS_SELECTED|LVIS_FOCUSED );

its not working.

is am i doing in the corret way?. if not how do it?.

Thanks..

From: David Lowndes on
>nItem=5;
> m_ListCtrl.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED,
>LVIS_SELECTED|LVIS_FOCUSED );
>
>its not working.

Is it not working, or are you just not seeing the selection indicator
when the control doesn't have focus?

Dave
From: vijay on
after SetItemState function, i am using the following code to check
whether the new row is effected or not

pos = m_ListCtrl.GetFirstSelectedItemPosition();
nItem = m_ListCtrl.GetNextSelectedItem(pos);

also, it is not having the foucs,so it is not displaying the selection
indicator.i need to scroll the selection status to the new row.

From: David Lowndes on
>after SetItemState function, i am using the following code to check
>whether the new row is effected or not
>
> pos = m_ListCtrl.GetFirstSelectedItemPosition();
> nItem = m_ListCtrl.GetNextSelectedItem(pos);

I'm not sure what's happening there. Have you just tried
GetNextItem(-1, LVNI_SELECTED) instead?

>also, it is not having the foucs,so it is not displaying the selection
>indicator.

Give the control the LVS_SHOWSELALWAYS style.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
From: vijay on
Thank you Mr.David Lowndes

i solved my problem. the problem is , when i use the "Next" button to
scroll to the next row, the list Control is losing its focus.

now i setting the focus to the list control again. then it is working
as i desired.

m_ListCtrl.SetFocus();
nItem=5;
m_ListCtrl.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED,
LVIS_SELECTED|LVIS_FOCUSED );

Once again Thanks Mr.David Lowndes