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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
*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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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"
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
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
    End Sub

Open in new window

BrianVSoftAuthor Commented:
Thanks IdleM. But No Mouse events at all..
See attached list of events..
 Events of ListBox in Compact
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..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Smartphone Programming

From novice to tech pro — start learning today.