Dave2001
May 1st, 1999, 08:13 PM
PLEASE HELP!
I need to find out how to create something like this using a CListCtrl.
Col 1|Col 2|Col 3
---------------------------------------------
A.....B.....C
I can get it set up with the columns, but I can't figure out how to insert items correctly into them.
Dave2001,
Dave2999@hotmail.com
Malc
May 5th, 1999, 02:47 AM
I expect you may have an answer by now, but if not...
To insert an item into your CListCtrl use:
int CListCtrl::InsertItem( int nItem, LPCTSTR lpszItem, int nImage )
There are other overloads of this member function, see the MFC documentation.
This will put the entry in the first column with text and an image (if you want one).
You then need to insert the data for the other columns with successive calls to:
BOOL CListCtrl::SetItem( int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem,
int nImage, UINT nState, UINT nStateMask,
LPARAM lParam );
You pass the item number returned by InsertItem as nItem (this identifies the row). The parameter nSubItem identifies the column. For the second column (you already did the first one), use 1. For the third column, use 2 etc. For each column you obviously need a separate call to SetItem. Again, see MFC documentation for details of the other parameters (some of these have default values).
Hope this helps.