Click to See Complete Forum and Search --> : listviewctrl (report) selecting & highlighting


panza
May 27th, 1999, 04:43 AM
Hey,

I'm using these lines to scroll & highlight to a specific item in my list... it *scrolls*,
but the line is not being selected/focues/highlighted. All examples from the
"selection"-part from the listview control topic here at codeguru don't work
either...

(I have set LVM_SETEXTENDEDLISTVIEWSTYLE & LVS_EX_FULLROWSELECT
before and it works great when clicking into the view)


m_liste.EnsureVisible( pos, NULL);
m_liste.SetItemState( pos, LVIS_SELECTED, LVIS_SELECTED);
m_liste.Update( pos);




I tried these other SetItemState-Calls - they all don't work (they all return a nonzero-value, so they
SEEM to do something, but nothing actually happens):


m_liste.SetItemState( pos, LVIS_SELECTED | LVIS_FOCUSED, LVIF_STATE);
m_liste.SetItemState( pos, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
m_liste.SetItemState( pos, LVIS_SELECTED, LVIF_STATE);




Any idea, anyone?

Thank you.


-.-.-

Stu
May 27th, 1999, 05:17 AM
Hi,

Hmm, you seem to be doing the right thing. The correct SetItemState() is:

m_liste.SetItemState( pos, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);



The only thing I can think of is that the list control is losing focus, so you not seeing your selection. Are you executing the 'selection' code as a result of pressing a button on the same dialog for example?

Try setting the list style LVS_SHOWSELALWAYS ("Show selection always" on the control properties) - this way you'll be able to see the selected item even if the list hasn't got focus...

As a last resort, try m_liste.SetFocus() before calling SetItemState()

Stuart

panza
May 27th, 1999, 11:57 AM
Hi,

you were right - the control needs the focus... so a simple SetFocus() did the job! :-)

Thanks!



-.-.-