[转]WinForms GridListEditor - How to restore values in the auto filter row

时间:2021-07-05 03:41:39

http://dennisgaravsky.blogspot.hk/2016/05/winforms-gridlisteditor-how-to-restore.html

 

using System;
using DevExpress.XtraGrid;
using DevExpress.ExpressApp;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.ExpressApp.Win.Editors;

namespace MainDemo.Module.Win {
    public class B152594 : ViewController<ListView> {
        GridListEditor gridlistEditor = null;
        protected override void OnViewControlsCreated() {
            base.OnViewControlsCreated();
            gridlistEditor = View.Editor as GridListEditor;
            if(gridlistEditor != null) {
                gridlistEditor.Grid.HandleCreated += Grid_HandleCreated;
            }
        }
        private void Grid_HandleCreated(object sender, EventArgs args) {
            GridControl grid = (GridControl)sender;
            grid.HandleCreated -= Grid_HandleCreated;
            using(var criteriaScope = View.ObjectSpace.CreateParseCriteriaScope()) {//!!!
                ((GridView)grid.MainView).GuessAutoFilterRowValuesFromFilter();
            }
        }
    }
}

[转]WinForms GridListEditor - How to restore values in the auto filter row