Solved

Finding the index of the item just added to a listview

Posted on 2004-08-10
2
217 Views
Last Modified: 2010-04-15
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
Comment
Question by:graham_ball
2 Comments
 
LVL 19

Accepted Solution

by:
drichards earned 50 total points
ID: 11764264
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
 

Author Comment

by:graham_ball
ID: 11764280
thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question