-
CListCtrl Question
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
-
Re: CListCtrl Question
Try this instead
CListCtrl* pList = (CListCtrl*) GetDlgItem(IDC_YOUR_LIST_ID);
pList->InsertItem(m_listCtrl.GetItemCount(), dlg.m_textQ);
-
Re: CListCtrl Question
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://[email protected]
-
Re: CListCtrl Question
Try this up...
int iTotalItem =m_ListControl.GetItemCount()
m_ListControl.InsertItem(iTotalItem,"");
m_ListControl.SetItemText(iTotalItem, 0,"Hello");
-
Re: CListCtrl Question
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