Listbox and enter key

Discussion in 'Questions (Windows Mobile)' started by tsteward, Oct 13, 2008.

  1. tsteward

    tsteward Active Member Licensed User

    I want to have a listbox where I can scroll up and down using the cursor keys (no problem here it does that by default) now I wish to trigger a sub when I press enter or cMiddle.

    Is this possible?
    How please?

    Thank you,

    Tony
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It is possible with the Door library:
    Obj is an Object and keyDownEvent is an Event (from the Door library).
    Code:
    Sub Globals
        
    'Declare the global variables here.

    End Sub

    Sub App_Start
        Form1.Show
        obj.New1(
    False)
        obj.FromControl(
    "Listbox1")
        keyDownEvent.New1(obj.Value,
    "KeyPress")
    End Sub

    Sub keyDownEvent_NewEvent
        obj.Value = keyDownEvent.Data
        
    If Asc(obj.GetProperty("KeyChar")) = 13 Then
            
    Msgbox("The following item was selected: " & _ 
                ListBox1.Item(ListBox1.SelectedIndex))
        
    End If
    End Sub
     
  3. tsteward

    tsteward Active Member Licensed User

    Thanks Erel,
    I knew door lib could do it I just didn't know enough to know how.

    Ta mate :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice