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

P

polocar

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
 
A

andy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top