1 頁面簡(jiǎn)單布局
2關(guān)鍵字過濾
在TextBox中輸入查詢關(guān)鍵字暖哨,即可医增。按table_name、comments字段模糊查詢
3高級(jí)過濾
在TextBox中輸入查詢完全查詢條件查詢莫瞬, 比如: table_name like '%user%'逼争;這里可以寫簡(jiǎn)單的表達(dá)式,可以支持算術(shù)運(yùn)算符=-*/ ;邏輯運(yùn)算符 and or not 像寒;以及 like 烘豹、in 等運(yùn)算。
4核心代碼
/// <summary>
/// DataGridView 過濾
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
DataTable dt = dataGridViewE1.DataSource as DataTable;
string sFilter = "";
if (checkBox1.Checked)
{
//高級(jí)過濾
sFilter = textBox1.Text;
}
else
{
sFilter = string.Format("Table_Name + comments like '%{0}%' ", textBox1.Text);
}
dt.DefaultView.RowFilter = sFilter;
}