ListView How to focus an item??

T

TN

I have a listview, i was wondering how can I focus an item in it? I am
updating a GUI periodically and clearing the view, so it loses focus, I
need a way to set this but can't find the right property.
 
M

Morten Wennevik [C# MVP]

TN said:
I have a listview, i was wondering how can I focus an item in it? I am
updating a GUI periodically and clearing the view, so it loses focus, I
need a way to set this but can't find the right property.

Hi TN,

Use ListView.EnsureVisible(int index) to force a certain ListViewItem to
become Visible.
 
I

Ignacio Machin ( .NET/ C# MVP )

I have a listview, i was wondering how can I focus an item in it? I am
updating a GUI periodically and clearing the view, so it loses focus, I
need a way to set this but can't find the right property.

You can use SelectedItem (or SelectedIndex) to mark it as selected and
then use EnsureVisible (you can use ListView.SelectedIndices[0] ) to
know which item is selected
 

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