• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Finding the index of the item just added to a listview

Given certain conditions, I want to change the background colour of an item I have just added to a listview, but I cannot see how to get the index of the added item.

thanks,
Graham
0
graham_ball
Asked:
graham_ball
1 Solution
 
drichardsCommented:
When you do the Add to the Items, a ListViewItem is returned to you.  You can check the Index property of the returned item, though it's not necessary since you already have the item in hand.

    System.Windows.Forms.ListViewItem item = listView1.Items.Add("New Item");
    // index of added item is 'item.Index'
0
 
graham_ballAuthor Commented:
thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now