   Adding items to list view/list control [FIXED]
  Thanks for taking the time to read my post. My problem concerns win32 list control (aka list view). I add a list view to my project in the resource editor, and I succesfully create three columns in it like this:LVCOLUMNlvc[3];lvc[0].mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;lvc[0].fmt= LVCFMT_LEFT;lvc[0].cx= 100;lvc[0].pszText= "Client";lvc[1].mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;lvc[1].fmt= LVCFMT_LEFT;lvc[1].cx= 100;lvc[1].pszText= "Packets sent";lvc[2].mask= LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;lvc[2].fmt= LVCFMT_LEFT;lvc[2].cx= 100;lvc[2].pszText= "Packets received";for (int i = 0; i < 3; i++)SendMessage(list_view[CLIENT_LIST_VIEW], LVM_INSERTCOLUMN, (WPARAM)i, (LPARAM)(LPLVCOLUMN)&lvc);This succeeds. The columns show in my program. But here comes the problem. When I try to add rows of data to the list view, I do not see anything at all. I tried various ways, my best idea is in the code box below. Please help me fix this code so I can add rows of data to my list view. Then I'd be in 7th heaven :)LVITEMlvi[3];for (int i = 0; i < 3; i++){lvi.mask= LVCF_TEXT;lvi.iItem= i;lvi.pszText= "Some text";SendMessage(list_view[CLIENT_LIST_VIEW], LVM_INSERTITEM, i, (LPARAM)(LPLVITEM)&lvi);}[Edited by - Subotron on June 17, 2006 7:47:14 AM]
  Try setting the iSubItem field of LV_ITEM to the column you want the text in:LV_ITEM lvi;char buf[64]for(j = 0;j < numrows;j++){lvi.iItem = j;//set row of this item   for(i=0;i < numcols;i++){lvi.iSubItem= i;//<-----set column of this itemlvi.pszText = sprintf(buf,"Row:%i Col:%i",j,i);//Insert item into list view control hereListView_InsertItem(list_view[CLIENT_LIST_VIEW], &lvi);   }}The field iItem is like the row-number and iSubItem the column number.Note also that there are WIN32 macros beginning with ListView_* that makes things clearer than using the SendMessage()'s.Also see Adding Subitems to ListviewsGood Luck.   ;  Thanks for the help, but that didn't work either. I don't see anything appear after the screenserver turns on either, like in that other topic. I also tried setting it at different points, just after the columns, or when I click some button. Nothing works :(   ;  Ok, got it to work now.I used your code above, and set the mask for each item to LVIF_TEXT, then after inserting the item I set the subitem to the desired col (turns out you can't do that before inserting the item, subitem has to be 0 there) and used LVM_SETITEM to update the items with their new columns.Thanks a lot! Now I'm going to figure out if I can get a selection-style list list boxes (where you select a whole row on click). My life has meaning again :)   