Solved

Finding the index of the item just added to a listview

Posted on 2004-08-10
2
216 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now