Filtering DataGridView without changing datasource

前端 未结 7 1971
渐次进展
渐次进展 2020-11-22 06:55

I\'m developing user control in C# Visual Studio 2010 - a kind of \"quick find\" textbox for filtering datagridview. It should work for 3 types of datagridview datasources:

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 07:32

    I just spent an hour on a similar problem. For me the answer turned out to be embarrassingly simple.

    (dataGridViewFields.DataSource as DataTable).DefaultView.RowFilter = string.Format("Field = '{0}'", textBoxFilter.Text);
    

提交回复
热议问题