1
It is possible to apply filter to a DataGridView
which is "filled" with a List
, without altering the DataSource
grid?
Example: When I have a grid that uses a BindingSource
I can apply a filter, like meuBindingSource.Filter = "coluna like 'valor%'"
.
Or when I fill the grid with a DataTable
I can do (dataGrid.DataSource as DataTable).DefaultView.RowFilter = "coluna like 'valor%'";
But when I fill the grid with a List
I can only get 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();