Listview Item Click will not be fired

  • Thread starter =?iso-8859-1?B?Qmr2cm4=?=
  • Start date
?

=?iso-8859-1?B?Qmr2cm4=?=

Hallo together,

I use the Listview in .NET CF under Visual Studio .NET 2003.
I am adding the LV Items like this at the runtime:


locLVItem = New ListViewItem
locLVItem.Text = "XYZ"
locLVItem.SubItems.Add("XY")
PubFrmMain.LView.Items.Add(locLVItem)
The problem is that the Listview provides an Click Event but it will never be started. Is the Click Event not usable in .NET CF?

The SelectedIndexChanged Event I cannot use because the event will be fired before the Item is focused and so I cannot find the Focused item in this event:

If CType(sender, ListView).Focused = True Then

PubLVClickIndex = CType(sender, ListView).FocusedItem.Index

End If



Can anybody help me?

Greetings BG
 
F

Flynn Arrowstarr

Hi, BG

The click event isn't supported by some of the controls
in the .NET CF. Instead, use the SelectedIndexChanged
event and search the ListView.SelectedIndexCollection to
find the selected item(s).

Hope that helps =)

Flynn
-----Original Message-----
Hallo together,

I use the Listview in .NET CF under Visual Studio .NET 2003.
I am adding the LV Items like this at the runtime:


locLVItem = New ListViewItem
locLVItem.Text = "XYZ"
locLVItem.SubItems.Add("XY")
PubFrmMain.LView.Items.Add(locLVItem)
The problem is that the Listview provides an Click Event
but it will never be started. Is the Click Event not
usable in .NET CF?
The SelectedIndexChanged Event I cannot use because the
event will be fired before the Item is focused and so I
cannot find the Focused item in this event:
 
E

Elmer Miller

The problem with the SelectedIndexChanged event is that it doesn't fire if
the user clicks an item that is already selected. If anyone knows how to get
a click event to work in ListView or TreeView, please post here. Thanks.
 
F

Flynn Arrowstarr

A correction to the McSoft package I referenced - it doesn't add a Click
event to the controls, it adds MouseDown, MouseUp, and DoubleClick
events (among other things).

Flynn
 
F

Flynn Arrowstarr

You're correct that the ListView control shows a Click event in
Intellisense. However, as you also pointed out, that Click event never
gets fired. The SelectedIndexChanged event works well for most things.

If you just want the index of the item that's focused, try this:

Dim item As ListViewItem
For Each item In lstView.Items
If item.Selected = True Then
PubLvClickIndex = item.Index
Exit For
End If
Next

You would fire this routine inside the SelectedIndexChanged event.

You could also extend the control yourself to add a Click event,
however, I'm not certain how to do that.

If all else fails, there is a package available for .NET CF developers
that adds the Click event to the CF controls. The package is available
from http://www.mcsoft.com.au/. I don't know how much the package costs,
but there is a demo version availbale.

Flynn
 

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