How to the item of listview selected automatically?

Y

yxq

Hello
I want to first item of listview selected automatically, i write the code,
but it does not work.

ListView1.Focus()
ListView1.Item(0).Select = True

Thanks
 
H

Herfried K. Wagner [MVP]

Hello,

yxq said:
I want to first item of listview selected automatically, i write
the code, but it does not work.

ListView1.Focus()
ListView1.Item(0).Select = True


Set the ListViewItem's 'Selected' property to 'True'. Notice that you need
not set the focus to the ListView control, you may want to set the ListView
control's 'HideSelection' property to 'False'.
 
N

Nick Hertl

yxq said:
Hello
I want to first item of listview selected automatically, i write the code,
but it does not work.

ListView1.Focus()
ListView1.Item(0).Select = True

Thanks

I'm surprised that even compiles.
Do you meen:

ListView1.Focus()
ListView1.Items(0).Select = True

[Note the "s" at the end of "Items"]
 

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