On Aug 30, 1:40 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
Hi,
"Dom" <dolivas...@gmail.comwrote in message
news:11**********************@r29g2000hsg.googlegr oups.com...
ListViewItem t = new ListViewItem();
for (...)
{
t.SubItems.Add (...);
}
ListView1.Add (t);
That looks fine, but how many columns do you have? I have never ever had a
need to do a for to add the subitems.
The problem is that the columns of the listview are shifted to the
right by one column. After debugging around, I found that "t = new
ListViewItem();" shows that t.SubItems.Count = 1. Where did that "1"
come from? Shouldn't it be "0"? It is still there after I do
t.Clear().
The first column is ListViewItem.Text, the second column are the SubItems.
Not only that, but SubItems[0] is the ListViewItem.Text !!!
That explain why t.SubItems.Count shows 1 instead of 0 as you were
expecting.
Thanks, Ignacio. That explains it for me. For the record, I do a
"for" loop to add the subitems because I don't know how many subitems
I need before hand. The user enters an Access filename, and then
chooses to list one of the Schema for the file, eg, the tables, or the
indexes. The information you get for the table (name, creation data,
etc), is not the same as the information you get for the indexes.
But your answer is what I needed. I'm going to add an initial column
that will just count off the row number.
Thanks, again