在gridview自动过滤器行中添加自定义按钮 [英] add custom button in gridview auto filter row

查看:863
本文介绍了在gridview自动过滤器行中添加自定义按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何添加按钮[x]以清除自动过滤器,以便我们不需要按删除或退格清除过滤器。这样的例子

how to add button [x] to clear auto filter so we dont need to press delete or backspace clear the filter. illustration like this

代码iam用于repositoryitemcombobox

for the code iam using for repositoryitemcombobox

   private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
    {
        if (gridView1.OptionsView.ShowAutoFilterRow == true)
        {

            for (int i = 0; i < gridView1.RowCount; i++)
            {

                  string code = gridView1.GetDataRow(i)["code"].ToString();
                    if (!repositoryItemComboBox1.Items.Contains(code))
                    {
                     repositoryItemComboBox1.Items.Add(code);
                    }                 
            }
            if (e.Column.FieldName == "genre" && view.IsFilterRow(e.RowHandle))
            {
                e.RepositoryItem = repositoryItemComboBox1;

            }

FYI:iam使用devexpress

FYI : iam using devexpress

推荐答案

(从我的头顶,我认为这是WinForms控件)

(From the top of my head, I assume this is for the WinForms controls)

你需要有两个RepositoryItem,一个没有清除按钮,另一个使用按钮(你可以通过RepositioryItem的Buttons属性添加按钮)。

You'll need to have two RepositoryItems, one without the clear button, and one with the button (you can add buttons via the RepositioryItem's Buttons property).

你会将RepositoryItem分配给相关列的附加按钮。

You'll assign the RepositoryItem without the additional button to the relevant column.

然后,您需要处理GridView的CustomRowCellEditEventHandler。检查事件的e.RowHandle是否等于GridControl.AutoFilterRow,如果是,则使用清除按钮将e.RepositoryItem分配给RepositoryItem。

Then you'll need to handle the GridView's CustomRowCellEditEventHandler. Check if the event's e.RowHandle equal GridControl.AutoFilterRow, and if so, assign e.RepositoryItem to the RepositoryItem with the clear button.

然后处理清除按钮RepositoryItem的ButtonClicked事件。

Then handle the clear button RepositoryItem's ButtonClicked event.

这篇关于在gridview自动过滤器行中添加自定义按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆