Reputation: 23
I have two DataGridView's bound to an underlying DataSource through BindingSources and TableAdapaters.
I have two models; strings and tables. Tables -> [id, handle, description] Strings -> [id, handle, table_id]
So there's a many-to-one between Tables and Strings.
What's the easiest way to make the selection of the "tables" DataGridView to filter the contents of the "strings" DataGridView?
I understand the datasource of the "strings" DataGridView can be set to the bindingsource of the "tables" DataGridView but this does not support multiple selection.
At the moment, when the selection on the "tables" DataGridView is changed, I am iterating over the selected rows and building a string-based filter for the "strings" DataGridView but I find this slow and messy.
Anyone know a nicer way?
Upvotes: 0
Views: 1653
Reputation: 93
You can just use two different BindingSources for each of the tables. Or you can fill the first table with just the data, without using a BindingSource at all. Then you can react on the SelectionChanged event from the DataGridView to set the filter on the BindingSource on table 2.
There's lots of ways: are you able of figuring out new ways yourself?
Upvotes: 0
Reputation: 36035
You might have some other issue with the code that is making it slow.
About it being messy, I usually just move code that lets me easily grab lists of elements to extension methods over the DataGridView. Built-in/simple is for single selection.
Upvotes: 1