dev gridcontrol设置过滤器下拉列表

  

调用:
            //为类别名称列启用选中的过滤器下拉式样式。
            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;
                //}
            }
        }

 注意调用时要存在对应的列。

原文地址:https://www.cnblogs.com/xifengyeluo/p/8193714.html