Home Forums WinForms controls Xceed Grid for WinForms Searching and filtering data in Xgreed Cells

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13370 |

    Well, imagine that I have a “text box”, a “button” and a loaded “xceed grid” on a form. Now, what I need is to insert some text into the “text box” a press the “button”. That would, “supposely”, search the “xceed grid” datarows collection for the specified text and then, retrieve me ONLY the rows that mach the “text box” text (*bla*, bla.*, “bla” etc…)

    Is this possible?

    Tks in advance!

    Imported from legacy forums. Posted by EFileTahi-A (had 3087 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes, this is possible.
    Instead of binding the GridControl to a DataTable, create a DataView on the DataTable, and bind the GridControl to the DataView. The DataView has a property RowFilter, that is a string you can use to filter the view.

    Imported from legacy forums. Posted by Tommy (had 214 views)

    User (Old forums)
    Member
    Post count: 23064

    God bless you tommy! Am going to try it this weekend…
    thank u very much

    Imported from legacy forums. Posted by EFileTahi-A (had 206 views)

    User (Old forums)
    Member
    Post count: 23064

    You just want to retrieve the rows? I thought you wanted to filter the grid, and hide the rows that don’t match.
    Here’s a function that returns an ArrayList with the matching rows for a specific text.<code>using System.Collections;
    using Xceed.Grid;
    using Xceed.Grid.Collections;

    private ArrayList MatchingDataRows(GridControl grid, string text)
    {
    ArrayList matchingRows = new ArrayList();

    DataRowList gridRows = grid.DataRows;
    int rowCount = gridRows.Count;
    int columnCount = grid.Columns.Count;

    text = text.ToLower();

    for(int i=0; i<rowCount; i++)
    {
    DataRow row = gridRows[i];
    CellList cells = row.Cells;
    for(int j=0; j<columnCount; j++)
    if (cells[j].GetTextToPaint().ToLower().Contains(text))
    {
    matchingRows.Add(row);
    break;
    }
    }

    return matchingRows;
    }</code>

    Imported from legacy forums. Posted by Tommy (had 4115 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.