Is it possible to apply filter to a DataGridView
that is "filled" with a List
, without changing the DataSource
of the grid?
Example: When I have a grid that uses a BindingSource
I can apply a filter, such as meuBindingSource.Filter = "coluna like 'valor%'"
.
Or when I fill the grid with a DataTable
I can (dataGrid.DataSource as DataTable).DefaultView.RowFilter = "coluna like 'valor%'";
But when I fill in the grid with a List
I can only simulate a filter, because I end up changing the DataSource
of the grid. Ex.:
var source = ((IEnumerable<Tipo>)dataGrid.DataSource).ToList();
var ds = source.Where(x => x.COLUNA.EndsWith(filtro));
dataGrid.DataSource = ds.ToList();