Filtering and grouping data in DataTable

The grid enables connection of different types of data sources. The programmer can add data by calling Grid.Rows.Add() / Row.Add() methods or from various data collections: IList, IBindinList, IListSource. The grid provides sorting, grouping, editing, filtering, painting and other services for any method of data addition.

An example of connecting DataSet to a grid with automatic column generation.

public void InitializeGrid(Grid grid, DataSet dataSet)
{
    grid.Headers.AutoGenerate = true;
    source.DataMember = "Orders";
    source.DataSource = dataSet;

    grid.Filter = new Filter(IsRowFiltered);
}


private bool IsRowFiltered(Row row)
{
    bool filtered = false;

    //The value may be null or DBNull
    if (row["amount"].Value is double)
    {
        double amount = (double) row["amount"].Value;
        filtered = (cbMinValue.Checked && amount < _filterMinVal) || (cbMaxValue.Checked && amount > _filterMaxVal);
    }
    return filtered;
}