Filter a table on keypresses

Discussion in 'Questions (Windows Mobile)' started by Offbeatmammal, May 29, 2008.

  1. Offbeatmammal

    Offbeatmammal Member Licensed User

    A small challenge...
    I've worked out how to filter a table on a specific text entry
    table1.Filter("ColName = '*xyz*'")

    I now have two questions wrapped up in one...

    1/ is it possible to (easily) find all entries in a column (or columns) that contain the characters X and Y (case insensitive but in that order) and filter on that so "abXcdYe", "abcXYde" and "XabcdeY" would all be shown

    2/ is it possible to build a string on a smartphone by simply trapping keys from the form (using the door library) and avoid the need for a visible text box? I'm guessing character 8 would need trapping as delete and while it's straightforward on a Dash or BlackJack (full QWERTY keyboard) on a T9 (Touch Dual) to a T20 device (Shadow) you'd have to allow for any of the possible key values (eg rather than filtering for X in a specific position filter on X,Z or @ for instance)

    To give you the scenario... I have a contact list and I want to rapidally allow a user to narrow down to a particular name by tapping in a few characters 9much like in some of the dialer apps) ... at it's simplest typing "off" (or hitting the OP key, the 4DF and 4DF key on the Shadow) to find "offbeatmammal" (or "office" or "bugoff externimators") and I'd be happy with that... if it could also find words that have an O/P followed by F/D/4 and F/D/4 (in any combination but in that order) it would be a huge bonus

    any thoughts most welcome ;)
  2. Erel

    Erel Administrator Staff Member Licensed User

    A small example is attached.
    I've only tested it on the desktop.
    Filtering is done with the Regex library.
    Sub Globals
    'Declare the global variables here.
        Dim keys(0)
    Dim pattern
    End Sub

    Sub App_Start
        keys() = 
    Array("[0]","[1]","[2ABCabc]","[3DEFdef]","[4GHIghi]" _ 
        pattern = 
    End Sub

    Sub Form1_KeyPress (specialKey)
    If IsNumber(Chr(specialKey)) OR specialKey = 8 Then
    If IsNumber(Chr(specialKey)) Then
                pattern = pattern & keys(
    Chr(specialKey)) & ".*"
    Else If specialKey = 8 Then
    If alStack.Count > 0 Then
                    pattern = SubString(pattern,
    End If
    End If
            txtFilter.Text = 
    regex.New2(pattern & "$",false,true)
            Match.Value = 
    Do While Match.Success
                txtFilter.Text = txtFilter.Text & match.String & 
                match.Value = Match.NextMatch
    End If
    End Sub

    Sub FillWithRandomData
    For i = 1 To 100
            name = 
    For i2 = 1 To 5
                name = name & 
            txtFull.Text = txtFull.Text & name & 
    End Sub
    Sub txtFull_KeyPress (key)
    End Sub

    Sub txtFilter_KeyPress (key)
    End Sub

    Attached Files:

  3. Offbeatmammal

    Offbeatmammal Member Licensed User

    this works really well for the list, but can't work out how to convert it so it's filtering a table now a textbox.
    will I need to maintain the textbox and reload the table based on the filtering on each keypress?
    it's not critical in the app at the moment but would be nice for my to have this funtion (for both T9, T20 and QWERTY devices)
  4. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible to directly filter the table in such way.
    What are you using the table for?
  5. dzt

    dzt Active Member Licensed User

  6. Offbeatmammal

    Offbeatmammal Member Licensed User

    I'm trying to replicate the contact picker on the smartphone... so as I type letters (or on T9 numbers) it reduces the list down. Reason for wanting to do it on the table (rather than textbox) is that I wanted to format the list to show name, cellphone and email in the list.

    Happy to go back to just showing name (actually was thinking about having a name list and next to it a synchronised table that users can tab between various phone numbers and email address etc)

    Short term I'm going to just scroll to the letter on a keypress and go from there... maybe we can have filtering in vNext ;)
  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