Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1140
Wild Card* Record Search?
posted

Does the ultracombo provide a property / method call for wild card auto complete / search functionality?  i.e.  I want the user to type in *asp* and get the records (wasp, asp) and filter the remaining out.  Im sure it will be easy enough to write, just curious to see if functionality already exists

Parents
  • 1140
    Verified Answer
    posted

    Like I imagined, this was not to hard to accomplish.  Just wanted to post the simple code I used in case someone else finds a need for it.  The code currently only works (well) with one wild card, more than one with this logic slows the operations down significantly; as you can see I am attempting all ascii characters so for each wild card you will have 256 results i.e. *asp* would return a result set of 512.  I'm sure regular expressions would be the more logical approach, but this was quick and easy and pretty much what I needed.

     

    private void ReplaceWildCardString(char WildCard, string Expression, ref Infragistics.Win.UltraWinGrid.UltraCombo Grid)

    {

    // initialize a new array list for temporary storage of the wild card replacement results

    ArrayList arrPossibilities = new ArrayList();if (!Expression.Contains(WildCard.ToString()))

    {

    foreach (UltraGridRow row in Grid.Rows)

    {

    if (row.Cells["CELL"].Value.ToString().Contains(Expression) || row.Cells["CELL"].Value.ToString().Contains(Expression.ToUpper()) || row.Cells["CELL"].Value.ToString().Contains(Expression.ToLower()))

    {

    row.Hidden =
    false;

    }

    else if (row.Cells["CELL"].Value.ToString().ToUpper().Contains(Expression) || row.Cells["CELL"].Value.ToString().ToLower().Contains(Expression) || row.Cells["CELL"].Value.ToString().Contains(BLOCKED EXPRESSION

    {

    row.Hidden =
    false;

    }

    else

    {

    row.Hidden =
    true;

    }

    }

    }

    else

    {

    // Hide all of the rows

    foreach (UltraGridRow row in comboReasonSearch.Rows)

    {

    row.Hidden =
    true;

    }

     

    // build a result set; loop all ascii characters and replace the wild card with each

    for (int i = 0; i < 256; i++)

    {

    Char rChar = Convert.ToChar(i);

    // add the current result to the arraylist

    arrPossibilities.Add(Expression.Replace(WildCard, rChar));

    }

    // for each result

    for (int i = 0; i < arrPossibilities.Count - 1; i++)

    {

    // for each row

    foreach (UltraGridRow row in Grid.Rows)

    {

    // if the "Cell" contains the result display the row

    if (row.Cells["CELL"].Value.ToString().ToUpper().Contains(arrPossibilities[i].ToString().ToUpper()))

    {

    row.Hidden =
    false;

    }

    }

    }

    }

    }

Reply Children
No Data