調用: //為類別名稱列啟用選中的過濾器下拉式樣式。 this.gridView1.Columns[4].OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList; //訂閱ShowFilterPopupCheckedListBox事件。(允許您在顯示之前定制選中的過濾器下拉列表。) this.gridView1.ShowFilterPopupCheckedListBox += new FilterPopupCheckedListBoxEventHandler(this.gridView1_ShowFilterPopupCheckedListBox); /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void gridView1_ShowFilterPopupCheckedListBox(object sender, DevExpress.XtraGrid.Views.Grid.FilterPopupCheckedListBoxEventArgs e) { //忽略非目標列,視具體情況而定 if (e.Column.FieldName != "Address") return; //是否不隱藏“選擇所有”項,true不隱藏,false隱藏 e.CheckedComboBox.SelectAllItemVisible = true; //定位和禁用包含特定值的檢查項。 for (int i = 0; i < e.CheckedComboBox.Items.Count; i++) { DevExpress.XtraEditors.Controls.CheckedListBoxItem item = e.CheckedComboBox.Items[i]; string itemValue = (string)(item.Value as FilterItem).Value; //設置對應選項不可選 //if (itemValue == "湖南")// || itemValue == "Condiments") //{ // e.CheckedComboBox.Items[i].Enabled = false; //} } }
注意調用時要存在對應的列。