How can a user select a ListBox item with stylus in Compact DotNet

It sounds elementary, but I can't find how to emulate a Click.Event in a ListBox in a WinCE6, compact framework App..
I know Click.Event is not supported, but there must be a way for a user to "Tap Select" the desired line in a ListBox.
LVL 5
BrianVSoftAsked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
*Not a compact framework developer*

Isn't there a SelectedIndexChanged() event?  This should fire when an item is selected and then you can make something occur...

Always check to make sure the current index is NOT -1 before proceeding though:
Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged
        Dim index As Integer = ListBox1.SelectedIndex
        If index <> -1 Then
            ' ... do something in here ...
        End If
    End Sub

Open in new window

0
 
BrianVSoftAuthor Commented:
Using List1_SelectedIndexChanged presents a small problem.. We always Pre.Select and HiLite the users previous selection in the ListBox.. This defeats the SelectedIndexChanged event. They could just press [Enter] but that key needs a dislocated thumb to reach, and they usually have Stylus in hand at this point. I guess I could HiLite the row below the desired row. That would at least force the list to scroll the desired line into the viewed area and the "SelectedIndexChanged" event would then work.  It would however look like a "dumb piece of programming"
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Not sure if you can do this in the compact framework...

Try this approach:
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
        For i As Integer = 0 To ListBox1.Items.Count - 1
            If ListBox1.GetItemRectangle(i).Contains(e.X, e.Y) Then
                Debug.Print("Clicked on Index: " & i & " --> " & ListBox1.Items(i).ToString)
                Exit For
            End If
        Next
    End Sub

Open in new window

0
 
BrianVSoftAuthor Commented:
Thanks IdleM. But No Mouse events at all..
See attached list of events..
 Events of ListBox in Compact
0
 
BrianVSoftAuthor Commented:
Looks like no solution to our particular problem.
The operators will have to use Arrow Down then press [Enter] - They won't be able to select the hi-lited line using the stylus..
As it turns out, using a stylus is very dangerous in a listbox because the "Stylus X & Y" positions are not accurate enough on most mobile devices we have used.. Eg. If you tap below the center of the desired line, you get the line below..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.