I have a ListView (lvwDocs) which has 2 columns (DocLink and ID). Here's the code I'm using to populate the ListView:
This populates all columns and all rows as expected.Code:Do While dataReader.Read itmListItem = New ListViewItem() itmListItem.Text = dataReader(0) For shtCounter = 1 To dataReader.FieldCount() - 1 If dataReader.IsDBNull(shtCounter) Then itmListItem.SubItems.Add("") Else itmListItem.SubItems.Add(dataReader(shtCounter)) End If Next shtCounter lvwDocs.Items.Add(itmListItem)
However, I want to add an icon next to each row. To achieve that, I change the last line of the code to:
The variable nIndex is initialised to 0 before the Do While loop. This successfully adds the desired icon, however, the 2nd ListView column is no longer populated, only the first column. Can anyone help get both columns populated, as per the 1st example, as well as the icon?Code:lvwDocs.Items.Add(itmListItem.Text, nIndex)




Reply With Quote