Search code examples
c#comboboxbindingsource

Get filtered result from BindingSource to table/dataset?


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?


Solution

  • Actually I believe I finally found a solution.

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