How to select first row in the listview control

G

Guest

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
 
C

Carlos J. Quintero [.NET MVP]

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
 
G

Guest

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 said:
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 said:
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
 
C

Carlos J. Quintero [.NET MVP]

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
 

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