By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 1,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

How to select the first item (the one at the top) of an ordered ListView object

P: n/a
Hi,
I'm using Visual C# 2005 (part of Visual Studio 2005 Professional
Edition), and I have the following problem:
I populate a ListView object with several items, and at the end of
this process I put a statement that orders the ListView by a certain
column and in a certain order (ascending or descending, it doesn't
matter). To do that, I have defined a derived class of the IComparer
class (as explained in the Visual Studio MSDN Library).
Now I would like to select the first item of the list (the one at the
top, in the first position), but if I write the statement

ListViewItem1.Items[0].Selected = true;

the first item of the NOT ordered list is selected (so, probably not
the item at the top, but an item in the middle of the list).
I have also tried to force the ListView ordering as first thing, and
then populate the list, but unfortunately the result is the same...

Do you know if there is a way to do that (a particular method or
property of the ListView class, a prestige game, or so on)?

Thank you very much

Apr 13 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 13 Apr, 11:45, "polocar" <polo...@tin.itwrote:
Hi,
I'm using Visual C# 2005 (part of Visual Studio 2005 Professional
Edition), and I have the following problem:
I populate a ListView object with several items, and at the end of
this process I put a statement that orders the ListView by a certain
column and in a certain order (ascending or descending, it doesn't
matter). To do that, I have defined a derived class of the IComparer
class (as explained in the Visual Studio MSDN Library).
Now I would like to select the first item of the list (the one at the
top, in the first position), but if I write the statement

ListViewItem1.Items[0].Selected = true;

the first item of the NOT ordered list is selected (so, probably not
the item at the top, but an item in the middle of the list).
I have also tried to force the ListView ordering as first thing, and
then populate the list, but unfortunately the result is the same...

Do you know if there is a way to do that (a particular method or
property of the ListView class, a prestige game, or so on)?

Thank you very much
Try the line in an event which will fire later or.

Apr 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.