Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting infos from List Control...

Status
Not open for further replies.

FORAND

Programmer
May 26, 2003
64
CA

Help me, i'm tired of this s***. (sorry about that)

I have a List Control (m_List). I've manage to put infos in it. Here is how I did :
---------------------------------------------
strItem.Format("SOME INFOS");
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_List.InsertItem(&lvi);

strItem.Format("SOME MORE INFOS");
lvi.iSubItem = 1;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_List.SetItem(&lvi);
---------------------------------------------

Now, i want to get the infos back when i select something in the list... How can I do this?


 
>> I have a List Control (m_List).

When you post be specific or even post the code. I will assume m_List is a CListCtrl object. To get the Text value from a column use CListCtrl::GetItemText(nItem, nSubItem) where nSubItem is the column index and nItem is the row index into the list.

To work in Windows Programming you need to learn how to use the SDK which can be found at msdn.microsoft.com. In this case the SDK for CListCtrl is quite helpful in solving your problem. Also on MSDN you will find many tutorials and code samples for fundamentals such as working with list controls.

-pete
 
Ok. But how do I know what is the number of the item (nItem) that was selected in the CListCtrl?

 
Ok, i got it.
--------------------------------------------------
POSITION p ;
p = m_List.GetFirstSelectedItemPosition();
while (p)
{
nSelected = m_List.GetNextSelectedItem(p);
}
--------------------------------------------------

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top