add custom button in gridview auto filter row

回眸只為那壹抹淺笑 提交于 2019-12-11 04:49:54

问题


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

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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/38864644/add-custom-button-in-gridview-auto-filter-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!