Hi all


I am trying to create ClistCtrl with check boxes and different columns in it.

BUT

ListCtrl m_listBox;

int

i;
CString strTemp;

m_listBox.Create(WS_CHILD|WS_VISIBLE|LBS_STANDARD|WS_HSCROLL, CRect(10,10,200,200),this, 111);


m_listBox.InsertColumn(0, _T("Column 1") , LVCFMT_LEFT, 50, 0);
m_listBox.InsertColumn(1, _T("Column 2") , LVCFMT_CENTER, 100, 1);
m_listBox.InsertColumn(2, _T("Column 3") , LVCFMT_RIGHT, 100, 2);

m_listBox.SetExtendedStyle(m_listBox.GetExtendedStyle()|LVS_EX_CHECKBOXES | LVS_REPORT );



for(i = 0; i < 10; i ++)
{

strTemp.Format(_T("item"), i + 1);
m_listBox.InsertItem(i, strTemp, 0);

strTemp.Format(_T("Subitem"), i + 1);
m_listBox.SetItemText(i, 1, strTemp);

strTemp.Format(_T("SubSubitem"), i + 1);
m_listBox.SetItemText(i, 2, strTemp);

}

after using this code i can see repetition of "item" with check boxes in single column.
please tell me what is wrong OR just write few lines of code for me.

regards

Abid

>>strTemp.Format(_T("item"), i + 1);

Format() function is very similar to sprintf() -- you need to add %d if you want the string to contain the value of i+1. strTemp.Format(_T("item %d"), i + 1);

i have tried it but does not work. i am using visual studio 2005 :(

i mean it does not work. i want 3 columns in my Clistctrl but i can see only on column. no heading of columns but only list of
item
item
item
item
item
item
item
item

hope you understand

:(

This article has been dead for over six months. Start a new discussion instead.