private GridView _view; //表格对象 #endregion Fields #region Methods /// <summary> /// 单击表格空间列头按钮 /// </summary> /// <param name="gridView"></param> /// <param name="fieldName"></param> /// <param name="currentStatus"></param> /// <returns></returns> public bool ClickGridCheckBox(DevExpress.XtraGrid.Views.Grid.GridView gridView, bool currentStatus) { bool result = false; if (gridView != null) { gridView.ClearSorting();//禁止排序 gridView.PostEditor(); DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo info; Point pt = gridView.GridControl.PointToClient(Control.MousePosition); info = gridView.CalcHitInfo(pt); if (info.InColumn && info.Column != null && info.Column.FieldName == _column.FieldName) { for (int i = 0; i < gridView.RowCount; i++) { gridView.SetRowCellValue(i, _column, !currentStatus); } return true; } } return result; }
public void ResetLayout(DevExpress.XtraGrid.Views.Grid.GridView view, string gridName) { RegUtils.DeleteSetting("GridLayout\\" + gridName); view.ClearColumnsFilter(); view.ClearGrouping(); view.ClearSorting(); if (view.GetType() == typeof(DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)) { var bandedView = (DevExpress.XtraGrid.Views.BandedGrid.BandedGridView) view; foreach (DevExpress.XtraGrid.Views.BandedGrid.GridBand band in bandedView.Bands) band.Visible=true; } }
public void LoadLayout(DevExpress.XtraGrid.Views.Grid.GridView view, string gridName, bool clearSortFilterGrouping = false) { if (!this.DesignMode) { var regPath = RegUtils.RegBasePath("GridLayout\\" + gridName); if (RegUtils.PathExists(regPath)) { view.RestoreLayoutFromRegistry(regPath.ToString()); if (clearSortFilterGrouping) { view.ClearColumnsFilter(); view.ClearGrouping(); view.ClearSorting(); } } } }