private bool ClickGridCheckBox(DevExpress.XtraGrid.Views.Grid.GridView gridView, string fieldName, bool currentStatus) { bool result = false; if (gridView != null) { //禁止排序 gridView.ClearSorting(); gridView.PostEditor(); detailData.ClearSorting(); detailData.PostEditor(); DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo info; System.Drawing.Point pt = gridView.GridControl.PointToClient(Control.MousePosition); info = gridView.CalcHitInfo(pt); if (info.Column != null && info.Column.FieldName == fieldName) { for (int i = 0; i < detailData.RowCount; i++) { detailData.SetRowCellValue(i, fieldName, !currentStatus); } return(true); } } return(result); }
/// <summary> /// 全选/全不选 /// </summary> /// <param name="gridView"></param> /// <param name="fieldName"></param> /// <param name="currentStatus"></param> /// <returns></returns> private bool ClickGridCheckBox(DevExpress.XtraGrid.Views.Grid.GridView gridView, string fieldName, bool currentStatus) { try { bool result = false; if (gridView != null) { 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 == fieldName) { for (int i = 0; i < gridView.RowCount; i++) { gridView.SetRowCellValue(i, fieldName, !currentStatus); } return(true); } } return(result); } catch { return(false); } }
private void Editor_MouseDown(object sender, MouseEventArgs e) { #if DebugTest Log += "-Editor_MouseDown"; #endif if (e.Button == MouseButtons.Left) { Int32 currentTime = System.Environment.TickCount; if ((mouseDownTime <= mouseUpTime) && (mouseUpTime <= currentTime) && (currentTime - mouseDownTime < DoubleClickTime)) { isDoubleClicking = true; RepositoryItemPopupBase repositoryItemPopupBase = null; if (gridView.FocusedColumn != null) { repositoryItemPopupBase = gridView.FocusedColumn.ColumnEdit as RepositoryItemPopupBase; } if (gridView.ActiveEditor.IsModified && gridView.OptionsBehavior.EditorShowMode == EditorShowMode.MouseDown && gridView.OptionsView.ShowButtonMode == ShowButtonModeEnum.ShowAlways || (repositoryItemPopupBase != null) && (!repositoryItemPopupBase.ReadOnly) && (repositoryItemPopupBase.ShowDropDown == ShowDropDown.DoubleClick) && (gridView.FocusedColumn != null) && (gridView.FocusedColumn.OptionsColumn.AllowEdit)) { } else { if (DataRowDoubleClick != null) { if (gridView.ActiveEditor != null) { gridView.ActiveEditor.DoValidate(); gridView.PostEditor(); gridView.CloseEditor(); } if (e is DXMouseEventArgs) { ((DXMouseEventArgs)e).Handled = true; } DataRowDoubleClick(this, e); } } mouseDownTime = 0; } else { #if DebugTest Log += string.Format("({0},{1},{2},{3})", mouseDownTime, mouseUpTime, currentTime, DoubleClickTime); #endif } } }
/// <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); }