Click to See Complete Forum and Search --> : CListCtrl Report View Columns


Jason Brooks
April 14th, 1999, 01:33 AM
Dear All,

How can I add items of Text to a list control in report view to columns other 1?

I thought the Item and iSubItem fields of LVITEM would fill in this information for me, but I can not get this to work.

Any thought's or the correct solution I would be grateful.

Regards
Jason.




// Taken from Header File. MFC Generated Code
public:
CLotteryDlg(CWnd* pParent = NULL); // standard constructor
CHeaderCtrl *m_Header;

// Dialog Data
//{{AFX_DATA(CLotteryDlg)
enum { IDD = IDD_LOTTERY_DIALOG };
CListCtrl m_Results_List;
//}}AFX_DATA



//Taken from my OnInitDialog

LVITEM jb2;
ZeroMemory(&jb2,sizeof(jb2));

jb2.mask=LVIF_TEXT;
jb2.iItem=1;
jb2.iSubItem=0;
jb2.pszText="Jason";
jb2.cchTextMax=20;


m_Results_List.InsertColumn(0,"Date",LVCFMT_CENTER,100,-1);
m_Results_List.InsertItem(&jb2);

m_Results_List.InsertColumn(0,"1",LVCFMT_CENTER,20,-1);
m_Results_List.InsertColumn(2,"2",LVCFMT_CENTER,20,-1);
m_Results_List.InsertColumn(3,"3",LVCFMT_CENTER,20,-1);
m_Results_List.InsertColumn(4,"4",LVCFMT_CENTER,20,-1);
m_Results_List.InsertColumn(5,"5",LVCFMT_CENTER,20,-1);
m_Results_List.InsertColumn(6,"6",LVCFMT_CENTER,20,-1);
m_Results_List.InsertColumn(7,"B",LVCFMT_CENTER,20,-1);
m_Results_List.InsertColumn(8,"Machine",LVCFMT_CENTER,70,-1);

jb2.iItem=2;
jb2.iSubItem=1;
jb2.pszText="help";
m_Results_List.InsertItem(&jb2);

m_Results_List.UpdateWindow();

// The result is that Only "Jason" gets added to Column 0 of the View.

jasebrooks@hot-splam-mail.com

please delete between the '-' cheers.

April 14th, 1999, 04:38 PM
Your on the right track. You need:

m_Results_List.SetItem(&jb2);

after InsetItem to update the 2-n columns, updating iSubItem for each column.

Robert Clark

Jason Brooks
April 15th, 1999, 12:33 PM
Robert, many thanks.

Jason.