Click to See Complete Forum and Search --> : Still trying to highlight a ListCtrl


September 3rd, 1999, 06:30 AM
I have a listctrl within my dialog box, yet have tried many times to highlight the first item in the list ( index 0 ).

I place the functions in the OnInitdialog part of my code,yet still i have had no success.

I have currently tried

m_List.SetItemState( 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);

m_List.EnsureVisible( 0, FALSE);

Someone please tell me what I am doing wrong.

DomDo
September 3rd, 1999, 06:46 AM
The first line you wrote is correct and sufficient... Did you use this function before the call to the parent OnInitiDialog ? You should perhaps also check the 'Show selection always' check box in the properties of the resource.

September 3rd, 1999, 07:46 AM
I have called the function within the OnInitDialog, just after all of the m_List.InsertItem calls.

I have also checked the properties box, and the show always selection is ticked.

However it still wont highlight. The text colour is black, and the background colour is light blue. If i click on one of the items in the list when running the program it highlights yellow. However it will not highlight the first item initially. Do you have any ideas ?

Many Thanks