Click to See Complete Forum and Search --> : CListCtrl Question
laiason5
May 24th, 1999, 05:11 PM
how do i insert an item into a list control?
i use InsertItem(nItem, CString) to insert it but it doesnt work.
this is the exact code i use:
m_listCtrl.InsertItem(m_listCtrl.GetItemCount(), dlg.m_textQ);
answers to why this wont help is appreciated.
thanks,
L5
Malamber
May 24th, 1999, 07:44 PM
Try this instead
CListCtrl* pList = (CListCtrl*) GetDlgItem(IDC_YOUR_LIST_ID);
pList->InsertItem(m_listCtrl.GetItemCount(), dlg.m_textQ);
Guodandan
May 24th, 1999, 07:55 PM
I am afraid you should insert at least one column into the ListCtrl before you insert any items. So try put following line in your OnInitDialog function or OnInitialUpdate():
m_listCtrl.InsertColumn(0, _T("ColumnHead Text"), LVCFMT_LEFT, 100, 0);
For more information about InsertColumn() see MSDN.
Good luck.
--
mailto://chinaufo@263.net
Jonathan
May 24th, 1999, 07:56 PM
Try this up...
int iTotalItem =m_ListControl.GetItemCount()
m_ListControl.InsertItem(iTotalItem,"");
m_ListControl.SetItemText(iTotalItem, 0,"Hello");
Mark Veldt
May 25th, 1999, 05:24 AM
if your CListCtrl is in report view, then you have to make the columns first.
m_ListCtrl.InsertColumn(1,"Directory",LVCFMT_LEFT,140,-1);
Mark
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.