HighTechTalks DotNet Forums  

How to select first row in the listview control

Dotnet Framework (WinForms) microsoft.public.dotnet.framework.windowsforms


Discuss How to select first row in the listview control in the Dotnet Framework (WinForms) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Steve
 
Posts: n/a

Default How to select first row in the listview control - 07-05-2005 , 07:56 AM






I have a form with listview control. The listview control is populated and
sorted in the begining. I want to select and highlight the very first row in
lietview control.

Unfortunately the following doesn't work:
m_FileList->Items->Item[0]->Selected = true ;

because Item[0] is not always displayed first. For example if the item array
is as follows:
Item[0] = "C"
Item[1] = "A"
Item[2] = "B"

Then after initial sorting m_FileList->Items->Item[0]->Selected = true ;
statement will highlight third row.

So my question is how can I select and highlight the very first row in
lietview control?

Thanks

Reply With Quote
  #2  
Old   
Carlos J. Quintero [.NET MVP]
 
Posts: n/a

Default Re: How to select first row in the listview control - 07-05-2005 , 08:16 AM






Try with the ListView.TopItem property


--
Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com


"Steve" <Steve (AT) discussions (DOT) microsoft.com> escribió en el mensaje
news:C6E37701-525C-4D3A-8D29-3FF0408FD954 (AT) microsoft (DOT) com...
Quote:
I have a form with listview control. The listview control is populated and
sorted in the begining. I want to select and highlight the very first row
in
lietview control.

Unfortunately the following doesn't work:
m_FileList->Items->Item[0]->Selected = true ;

because Item[0] is not always displayed first. For example if the item
array
is as follows:
Item[0] = "C"
Item[1] = "A"
Item[2] = "B"

Then after initial sorting m_FileList->Items->Item[0]->Selected = true ;
statement will highlight third row.

So my question is how can I select and highlight the very first row in
lietview control?

Thanks



Reply With Quote
  #3  
Old   
Steve
 
Posts: n/a

Default Re: How to select first row in the listview control - 07-05-2005 , 09:18 AM



I don't think your suggestion would work because I only can get
ListView.TopItem property value. I can't set it.

"Carlos J. Quintero [.NET MVP]" wrote:

Quote:
Try with the ListView.TopItem property


--
Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com


"Steve" <Steve (AT) discussions (DOT) microsoft.com> escribió en el mensaje
news:C6E37701-525C-4D3A-8D29-3FF0408FD954 (AT) microsoft (DOT) com...
I have a form with listview control. The listview control is populated and
sorted in the begining. I want to select and highlight the very first row
in
lietview control.

Unfortunately the following doesn't work:
m_FileList->Items->Item[0]->Selected = true ;

because Item[0] is not always displayed first. For example if the item
array
is as follows:
Item[0] = "C"
Item[1] = "A"
Item[2] = "B"

Then after initial sorting m_FileList->Items->Item[0]->Selected = true ;
statement will highlight third row.

So my question is how can I select and highlight the very first row in
lietview control?

Thanks




Reply With Quote
  #4  
Old   
Carlos J. Quintero [.NET MVP]
 
Posts: n/a

Default Re: How to select first row in the listview control - 07-06-2005 , 04:22 AM



You can use ListView.TopItem.Selected=True,
ListView.TopItem.EnsureVisible(), etc.

--
Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Steve" <Steve (AT) discussions (DOT) microsoft.com> escribió en el mensaje
news:3886032B-49DE-40B4-9539-003AF6E6366F (AT) microsoft (DOT) com...
Quote:
I don't think your suggestion would work because I only can get
ListView.TopItem property value. I can't set it.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.