So I have a dataGridView and a textbox on a form. I want to be able to search through the dataGridView and sort it compared to the string in the text box. ex:
I type “acv” in the text box and all strings containing “acv” are sorted to the top.
I’m accomplishing this with a bunch of gymnastics involving datatable.select and some clearing and filling but it’s ugly and slow. What would be the best practice/proper/normal way to do this?
So I have a dataGridView and a textbox on a form. I want to
Share
Use a filtered DataView and then set your DataGridView’s BindingSource to the Filtered DataView. If the user clears the filter condition, then just set the BindingSource back to your original default view. I recommend you store the view before sorting so you can go back to the original dataview easily. I use this now for sorting fast and it works great. Replace column names with yours. You should be able to modify the dataview from the original DataGridView and apply the filter without re-binding. Just bind your DataGridView to a DataView at the beginning, then retrieve the DataView (i.e. DataSource) and modify. I’m not sure if you are using a BindingNavigator or not. Good luck.