Ok, I searched the archives and have asked this question before with no response so I am asking it again. I am still trying to select an item in the CListCtrl. Current I have the following code:
CListCtrl = *m_pPlist = (CListCtrl *)GetDlgItem(IDC_LISTCTRL);
POSITION pos = m_pPList->GetFirstSelectedItemPosition();
If there are 5 listed items and none is selected pos is always NULL. If I select one of the items with the mouse then it works. I want just want to click on a button, which I have created, to begin processing the items in the list. I need to automatically go to the first item on the list and then select it.
Can't find out how to set the selected item to the first postion automatically without having to use the mouse to select the item.
Any help will be appreciated.
Mike@spb
John E
December 3rd, 2002, 11:30 AM
I've never actually done this but from the documentation it looks as though CListCtrl::GetItemState() and CListCtrl::SetItemState() are intended for this purpose. They allow you to set an item's state (for example to be LVIS_SELECTED) by knowing it's index.
You can also change an item's position by using CListCtrl::GetItemPosition() and CListCtrl::SetItemPosition() - again by using the item's index.
http://www.codeguru.com/forum/archive/index.php/t-221250.html Ok, I searched the archives and have asked this question before with no response so I am asking it again. I am still trying to sele