這篇文章主要介紹了c# GridControl的模糊查詢實現程式碼,需要的朋友可以參考下
##如上圖所示,如果查詢供應商名稱包括機械的公司,正常設定是不可以的,只能從頭開始篩選:方法1:
/// <summary> /// 设置girid为每一列都模糊搜索 /// </summary> /// <param name="gdv"></param> public static void SetFilter( DevExpress.XtraGrid.Views.Grid.GridView gdv ) { gdv.OptionsView.ShowAutoFilterRow = true; //gdv.OptionsFilter.AllowMultiSelectInCheckedFilterPopup = true; foreach (DevExpress.XtraGrid.Columns.GridColumn item in gdv.Columns) { item.OptionsFilter.AutoFilterCondition = DevExpress.XtraGrid.Columns.AutoFilterCondition.Contains; //筛选条件设置为包含 item.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList;//设置为过滤是可以多选 } }在要查詢的窗體中被呼叫即可:
SetFilter( gridView2 );
private void gridView1_CustomDrawRowIndicator( object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e ) { foreach (DevExpress.XtraGrid.Columns.GridColumn item in gridView1.Columns) { item.OptionsFilter.AutoFilterCondition = DevExpress.XtraGrid.Columns.AutoFilterCondition.Contains; //筛选条件设置为包含 } }
以上是c# GridControl的模糊查詢實現程式碼實例的詳細內容。更多資訊請關注PHP中文網其他相關文章!