Autocomplete combo box???

Discussion in 'Questions (Windows Mobile)' started by Ricky D, Sep 7, 2008.

  1. Ricky D

    Ricky D Well-Known Member Licensed User

    :sign0085:

    Hi people,

    I have written an app on my winmobile 6 ppc in VB.NET but am having what I think are memory leak problems and possibly problems with it's garbage disposal methods.

    What I'd like to do is write my app in Basic4ppc but I need to have the functionality of an autocomplete combobox. I've created one in vb.net and would like to know if anyone has managed to implement something like this in Basic4ppc?

    regards,

    Ricky
     
  2. Cableguy

    Cableguy Expert Licensed User

    Last edited: Sep 8, 2008
  3. Ricky D

    Ricky D Well-Known Member Licensed User

    Thanks but doesn't really help

    Thanks Cableguy but this isn't what I need.

    I need to be able to write it in Basic4ppc.

    I have tried to do this with a TextBox and a ListBox.
    The TextBox is where the user types.
    The ListBox contains items that will be searched.

    a Textbox in basic4ppc only has GotFocus, KeyPress and LostFocus events.

    The one I created in VB.NET for mobile uses a combo box and textbox and the critical code is in the KeyUp event of the textbox - Basic4ppc doesn't have this event.

    or are you suggesting I compile the code in the article you suggested and create it as a dll? If so I'm not sure how to do that and make it work in Basic4ppc.

    I'm not sure what you are saying. :sign0013:
     
  4. Cableguy

    Cableguy Expert Licensed User

    The code in the artical I referd you to, can easely be converted to a DLL and be used from b4p.
     
  5. BjornF

    BjornF Active Member Licensed User

    I think this works, after a fashion - there might be a better way of doing it...;)


    Code:
    Sub Globals
       
    'Declare the global variables here.
    End Sub

    Sub App_Start
       frm1.Show

       lstbox1.Add(
    "and let us start")  
       lstbox1.Add(
    "first")
       lstbox1.Add(
    "firstly")
       lstbox1.Add(
    "firstlyfinal")
       lstbox1.Add(
    "last")
    End Sub


    Sub TxtBox1_KeyPress (key)
       timer1.Enabled=
    True     'essentially works like a key-up, choose a good interval
    End Sub


    Sub Timer1_Tick
       timer1.Enabled=
    false
       
       txt=txtbox1.Text
       
    For i=0 To lstbox1.Count-1
          
    If StrIndexOf(lstbox1.Item(i),txt,0)=0 Then
             txtbox1.Text=lstbox1.Item(i)
             txtbox1.SelectionStart=StrLength(txt)
             txtbox1.SelectionLength=StrLength(lstbox1.Item(i))
             
    Exit
          
    End If
       
    Next
    End Sub
    (doesn't work with backspace/delete at present though)

    all the best / Björn
     
    Last edited: Sep 9, 2008
  6. Mr_Gee

    Mr_Gee Active Member Licensed User

    Thats works pretty well actually... good job :)
     
  7. Ricky D

    Ricky D Well-Known Member Licensed User

    the interval?

    Looks good. What is the timer interval?

    regards, Ricky
     
  8. Ricky D

    Ricky D Well-Known Member Licensed User

    Interval

    I set the interval at 50ms. Works fine.

    Now to figure out the backspace and delete issue....

    thanks guys

    Ricky
     
  9. BjornF

    BjornF Active Member Licensed User

    New improved version :)
    Now with support for backspace,
    delete also seems to work after a fashion

    Code:
    Sub Globals
       
    'Declare the global variables here.
       Dim Backspace
    End Sub

    Sub App_Start
       frm1.Show
       lstbox1.Add(
    "and let us start")
       lstbox1.Add(
    "first")
       lstbox1.Add(
    "firstly")
       lstbox1.Add(
    "firstlyfinal")
       lstbox1.Add(
    "last")
    End Sub


    Sub TxtBox1_KeyPress (key)
       
    If key=Chr(8Then
          Backspace=
    True
       
    Else
          Backspace=
    False
       
    End If
       timer1.Enabled=
    True
    End Sub

    Sub Timer1_Tick
       timer1.Enabled=
    false
       
       txt=txtbox1.Text
       
    If Backspace AND StrLength(txt)>0 Then
          txt=SubString(txt,
    0,StrLength(txt)-1)
       
    End If
       
       
    For i=0 To lstbox1.Count-1
          
    If StrIndexOf(lstbox1.Item(i),txt,0)=0 Then
             txtbox1.Text=lstbox1.Item(i)
             txtbox1.SelectionStart=StrLength(txt)
             txtbox1.SelectionLength=StrLength(lstbox1.Item(i))
             
    Exit
          
    End If
       
    Next
    End Sub
    all the best / Björn
     
    Last edited: Sep 10, 2008
  10. Ricky D

    Ricky D Well-Known Member Licensed User

    Thanks

    That works great.

    I have found the Del key doesn't fire the KeyPressed event.

    It doesn't worry me much.

    regards, Ricky

    P.S I've changed my code to use a combobox and have the textbox cover the text part of the combobox, still showing the dropdown arrow.
    On the combobox's SelectionChanged event I set the textbox's text to the item selected.
     
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