473,473 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
1 2042
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Islam Elkhayat | last post by:
In my Application i search my Employee database and view result in List View with 3 column.. here is the code: ######################################### private void textBox1_TextChanged(object...
11
by: Neo Geshel | last post by:
I have an Access DB, from which I am going to pull images. Each image has an associated ID, but the ID's are not necessarily sequential (some images may have been deleted, leaving gaps in the list...
5
by: Richard Bond | last post by:
I'm having a lot of trouble programatically selecting a listview item. How do you do this? These didn't work for me in the context of the sub below (that's trying to move up an Item in the...
1
by: Shane | last post by:
I have a text box select items in a listview as text is being typed into the text box. I get the select bar to move correctly in the Listview control. If the user presses the down or up key in...
3
by: rlg | last post by:
We have C# 2005 multi-threaded app. A background thread is processing data and periodically updating the contents of a ListView. Sometimes, the user clicking on a ListView item will not select...
5
by: Phill W. | last post by:
(VB'2003) What's the correct way to remove multiple, selected items from a ListView control (say, from a ContextMenu)? I ask because I'm getting a very annoying ArgumentOutOfRangeException...
1
by: apondu | last post by:
Hi, This is Govadhan, i am a begginer for web services using c#.net. I have written a small web service where in i have created a listview item in the web service method and added some data to...
0
by: =?Utf-8?B?Q2FibGVHdXk=?= | last post by:
If I have an unsorted listview I know I can select the first Item by ListView.Items.Selected = true. How do I select the first item in a sorted listview? Thanks. CableGuy
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.