Home Forums WinForms controls Xceed Grid for WinForms Best way to search a grid?

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

    I’ve got a GridControl where each DataRow contains an object that looks like the following:

    public interface IMyInterface
    {
    string Name { get; set; }
    Guid Id { get; set; }
    IProperty[] Properties { get; set;}
    }

    where IProperty is an interface for describing object properties (type, value, name, units of measure, etc). As each object is added, all of its property values are added to the row. It’s possible for an object to have a property that matches the Id field. The grid uses unbound data.

    What’s the best way to construct and search such a grid? I’ve been sticking the guid into DataRow.Tag property, but this makes searching quite cumbersome: I wanted to iterate over the GridControl.DataRows property until I found the object of my search, but I can’t seem to find a way to get an IEnumerator object for a DataRowList object. That leaves me with doing a foreach and interating over the entire grid.

    Does the GridControl offer a more performant way to execute searches? (I can’t simply put a hidden column into each row and throw the guid in there since it’s possible for that value to appear as legitimate data.) Failing that, how do I actually get an IEnumerator object for a DataRowList object? I checked out the FilterAndSearch demo, but that seems to imply that I always have to iterate over every row all the time, even if I’ve found what I’m looking for.

    Imported from legacy forums. Posted by Mike (had 2098 views)

    User (Old forums)
    Member
    Post count: 23064

    There is no other way. Only a foreach on the DataRows collection and verifying the value will do it.

    Imported from legacy forums. Posted by André (had 2908 views)

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