Solved

Finding the index of the item just added to a listview

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

15 Experts available now in Live!

Get 1:1 Help Now