Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert data into CListCtrl columns

Status
Not open for further replies.

victor7

Programmer
Jul 30, 2002
11
0
0
US
I'm having trouble dispalying info into a ReportView style CListCtrl. So far I can only display information in the first column but not in the second column. Can you tell me what I'm doing wrong here.

// Creating columns
m_listDevice.InsertColumn( 0, "DevName",LVCFMT_LEFT, 50);
m_listDevice.InsertColumn( 1, "Time", LVCFMT_LEFT, 50);

// Insert into columns
int index = m_listDevice.GetItemCount();
LV_ITEM item;
memset(&item, 0, sizeof(LV_ITEM));
item.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE;
item.iItem = index;
item.iImage = 1;
item.iSubItem = 0;
item.pszText = pDevice->m_csName;
item.lParam = (long)pDevice;
index = m_listDevice.InsertItem(&item);

item.iItem = index;
item.pszText = "3:05";
item.iSubItem = 1;
item.lParam = NULL;
item.iImage = 1;
m_listDevice.SetItem(&item);

thanks

 
Hi

Well, it drives me mad, as it looks like the code I used hundred of times but I finally found a way to do it ... while not really understanding and now it's working and wky it was not working

Simply redefined your mask for the subitem as

item.mask = LVIF_TEXT | LVIF_IMAGE;

and do not define you lparam

HTH

Thierry


 
Thanks a lot Thierry. I was getting really restless looking at the same few lines of code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top