private bool AllowOpenEditorOnMouseDown(XGridView view, GridHitInfo gridHit, int focusedRowHandle) { if (gridHit == null || gridHit.Column == null || !(gridHit.Column.RealColumnEdit is RepositoryItemTextEdit)) { return(true); } // grid focused and cell focused if (!this.dontOpenEditor && gridHit.RowHandle == focusedRowHandle && gridHit.Column == view.FocusedColumn) { return(true); // !this.dontOpenEditor; } bool buttonVisible; if (view.OptionsView.ShowButtonMode == ShowButtonModeEnum.ShowAlways) { buttonVisible = true; } else if (view.OptionsView.ShowButtonMode == ShowButtonModeEnum.ShowForFocusedRow) { buttonVisible = gridHit.RowHandle == focusedRowHandle; } else if (view.OptionsView.ShowButtonMode == ShowButtonModeEnum.ShowForFocusedCell) { buttonVisible = gridHit.RowHandle == focusedRowHandle && gridHit.Column == view.FocusedColumn; } else { buttonVisible = false; } if (!buttonVisible) { return(false); } var gridViewInfo = view.ViewInfo; var cellInfo = gridViewInfo.GetGridCellInfo(view.FocusedRowHandle, view.FocusedColumn); ButtonEditViewInfo editViewInfo = cellInfo.ViewInfo as ButtonEditViewInfo; if (editViewInfo == null) { return(!this.dontOpenEditor); // standard text edit (w/o buttons) } var point = gridHit.HitPoint; point.Offset(-cellInfo.Bounds.Left, -cellInfo.Bounds.Top); var hit = editViewInfo.CalcHitInfo(point); return(hit.HitTest == EditHitTest.Button || hit.HitTest == EditHitTest.Button2); }
/// <summary> /// Raises the LoadLayout event. Requires that PopulateGrid() has been called before /// </summary> /// <returns>true if an eventhandler is installed </returns> public bool RaiseLoadLayout() { GridLayoutEventArgs args = new GridLayoutEventArgs(this, this.LayoutId); try { XGridView view = this.MainView as XGridView; view?.SaveInitialLayout(); this.LoadingLayout?.Invoke(this, args); if (!args.Handled && this.AllowDefaultLoadingLayout) { DefaultLoadingLayout?.Invoke(this, args); } } catch { } return(args.Handled); }
private void gview_MouseDown(object sender, MouseEventArgs e) { XGridView view = (XGridView)sender; int focusedRowHandle = view.FocusedRowHandle; var hit = view.CalcHitInfo(e.Location); if (!view.IsDataRow(hit.RowHandle) && hit.RowHandle != NewItemRowHandle) { return; } if (e.Button == MouseButtons.Left) { if (ModifierKeys == Keys.None) { if (hit.RowHandle != focusedRowHandle) { // diese Zeile hat das Problem, dass wenn eine teilweise am unteren Rand sichtbare Zeile gewählt wird, die TopRow 2x geändert wird und man dann eine andere Zeile markiert //SelectFocusedRow(view, hit.RowHandle); this.BeginInvoke((Action)(() => view.SelectRow(hit.RowHandle))); } else if (e.Clicks == 1 && AllowOpenEditorOnMouseDown(view, hit, focusedRowHandle)) { this.dontOpenEditor = false; return; } this.timerEditDelay.Start(); } else { if (ModifierKeys == Keys.Control && !view.IsRowSelected(hit.RowHandle)) { this.BeginInvoke((Action)(() => view.SelectRow(hit.RowHandle))); } } } else if (e.Button == MouseButtons.Right) { if (!view.IsRowSelected(hit.RowHandle)) { SelectFocusedRow(view, hit.RowHandle); } } this.dontOpenEditor = true; }
public GridLayoutEventArgs(XGridControl gc, string controlId) { this.GridControl = gc; this.GridView = (XGridView)gc.MainView; this.ControlId = controlId; }