Use a filtered DataView, and then set the DataGridView BindingSource to a Filtered DataView. If the user clears the filter condition, simply set the BindingSource back to the original default view. I recommend that you keep the view before sorting so that you can easily return to the original dataview. I use it now for quick sorting and it works great. Replace the 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 the DataView at the beginning, then retrieve the DataView (i.e. DataSource) and modify. I'm not sure if you use BindingNavigator or not. Good luck.
Dim myDataTable As DataTable = myDataSet.Tables(0)
Dim myDataView As New DataView(myDataTable)
myDataView.RowFilter = "CompanyName LIKE '%" & ddlAlpha.SelectedItem.Text & "%'"
myDataView.Sort = "ContactName"
dataGridView1.DataSource = myDataView
dataGridView1.DataBind()
user195488
source
share