Reputation: 491
How can i get the index when adding my item to the ListView?
Im adding the item as follows
flatListView1.Items.Add(name).SubItems.AddRange(row1);
Upvotes: 2
Views: 969
Reputation: 9261
var lviewItem=flatListView1.Items.Add(name)
var index=flatListView1.Items.IndexOf(lviewItem)
Upvotes: 2
Reputation: 148110
You may need this, as the item added at the end of listitem and will be last. So total items -1 will be index because index starting from zero.
flatListView1.Items.Add(name).SubItems.AddRange(row1);
int index = flatListView1.Items.Count -1;
Upvotes: 2