add custom button in gridview auto filter row
Asked Answered
S

2

1

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

img1

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 using devexpress

Say answered 10/8, 2016 at 5:6 Comment(0)
C
0

Is it devexpress' grid view, isn't it? I don't know if this solution will suit your needs, but you can insert normal button control near grid and put code from answer on this site, inside click action.

EDIT: Found answer for your question - unfortunately it's not possible to add custom button to auto filter row

Chuipek answered 10/8, 2016 at 5:52 Comment(7)
yes, its devexpress, so we cant input button at repository item combobox?Say
i have try it, nothing works, also its not what i want (no clear button).Say
Maybe add custom column with button inside like here?Chuipek
i think that was not winform, which's i dont understandSay
Found this example. Please try it, and tell if it works :)Chuipek
eem, i think that was not what i want either :( from title u can see it's for column header, i believe its differrent when implementing it at my autofilterrow, because its already got repository combo box item.. :(Say
so it cant be implement ? thaxnksSay
J
0

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

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).

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

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.

Then handle the clear button RepositoryItem's ButtonClicked event.

Joy answered 28/9, 2016 at 8:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.