C# – Get filtered result from BindingSource to table/dataset

bindingsourceccombobox

I'm using a BindingSource connected to a DataGridView to filter the data shown.

I would like to know what is the best way to get the filtered result to some other thing than a GridView?

I ask this as I would like to use the filtered result for a few ComboBoxes. Right now I populate these by the DataTable that gets filtered by the BindingSource.

So in short, how do I get filtered BindingSource result as source for something else than a DataGridView?

Best Answer

Actually I believe I finally found a solution.

sourceDataTable.DefaultView.RowFilter = bindingSource.Filter;
DataTable destinationDataTable = sourceDataTable.DefaultView.ToTable();