Re: ListView events



Thank you, it helps

"Peter Foot [MVP]" wrote:

You don't need to loop through the collection to find the selected items -
use the SelectedIndices property. e.g.

If ListView1.SelectedIndices.Length > 0 Then
MessageBox.Show(ListView1.SelectedIndices(0).ToString)
End If

An item may be selected but not currently have the focus (indeed the focus
may be on another control).

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

"elena" <elena@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E76CBA58-38C7-49C5-9D3F-D071BBBECC65@xxxxxxxxxxxxxxxx
Hi, Peter
the following code doesn't work:

Private Sub ListView1_ItemActivate(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListView1.ItemActivate
MsgBox(ListView1.FocusedItem.Text)
End Sub

This one display message:

Private Sub ListView1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ListView1.SelectedIndexChanged
Dim item As ListViewItem

For Each item In ListView1.Items
If item.Selected = True Then
ClickIndex = item.Index
MsgBox(ClickIndex.ToString)
Exit For
End If
Next
End Sub

Please, advice
Thank you


"elena" wrote:

Hi, All
I have ListView1 populated with one column (.NET 2003 version 1.1, SP3)
I need to populate second ListView2 with a few columns when user selects
row
from ListView1.
I tried to extract the value of the selected row in
ListView_SelectedIndexChanged() event and ListView_ItemActivate(), but
seems
it doesn't work.
What event fires when row selected in the ListView? Or how can i activate
event?
Please, advice
Thank you

.



Relevant Pages

  • Re: How to detect which ListView item user clicks?
    ... He clicked on a listviewitem and as a result the SelectedIndexChanged event fires twice. ... Darren Shaffer .NET Compact Framework MVP ... or inspect the SelectedIndices array if not. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: ListView events
    ... You don't need to loop through the collection to find the selected items - use the SelectedIndices property. ... Private Sub ListView1_ItemActivate(ByVal sender As Object, ... Dim item As ListViewItem ... Please, advice ...
    (microsoft.public.dotnet.framework.compactframework)