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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CListView columns

Status
Not open for further replies.

BeegOrange

Programmer
Nov 7, 2002
8
IN
Hi,

I just cant seem to find the way to populate columns in a list view.

That is, I CAN POPULATE THE FIRST COLUMN, but not second, third etc! How exactly is it done??

I have used code like this:

1. theCtrl.InsertItem(0, fd.cFileName , NULL);

and

2. theCtrl.InsertItem(LVIF_TEXT|LVIF_STATE, i++, fd.cFileName ,(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,0, 0);

But how do I get to the subsequent columns?

Thanks in advance!
 
Hi, once you have inserted your initial item into the first column you can add text to the subsequent columns by using this method:

[tt]theList.SetItemText(listIndex,colNum,"Some Text");[/tt]

where [tt]theList[/tt] is the name of your list view control variable and [tt]listIndex[/tt] is the zero-based index of the item in the list (ie. item '0' would be the very first list item at the top) and [tt]colNum[/tt] is the actual column number (from the left): so if you specify '2' as the column number, the text would be inserted in the third column!

Hope this is what you're after!!

[rockband]
tellis.gif

programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.
 
Gednick,

Thnx a million! Exactly what I was looking for. You are a regular life-saver.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top