void m_deleteContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { try { ToolStripItem tsItem = e.ClickedItem; if (tsItem.Tag != null) { ContextItemClickedEventArg arg = new ContextItemClickedEventArg(); arg.Item = e.ClickedItem; DataGridViewHitTestType hitTestType = hitTestInfo.Type; if (hitTestType == DataGridViewHitTestType.Cell) { arg.Data = this;//.Rows[hitTestInfo.RowIndex]; } if (OnContextMenuItemClicked != null) { OnContextMenuItemClicked(sender, arg); } } } catch (Exception oEx) { LoggingHelper.ShowMessage(oEx); } }
private void _dgvGrid_MouseUp(object sender, MouseEventArgs e) { // for testing i guess try { if (e.Button == MouseButtons.Left) { _hti = DataGridView.HitTest(e.X, e.Y); _htt = _hti.Type; //if (_htt == DataGrid.HitTestType.Cell && _dgvBaseGrid.CurrentCell.ColumnIndex == 0) if (_htt == DataGridViewHitTestType.Cell) { //if (_dg[_dg.CurrentRowIndex, 0].ToString().Length == 0) // _dg[_dg.CurrentRowIndex, 0] = false; //else if (_dg[_dg.CurrentRowIndex, 0].ToString() == "True") // _dg[_dg.CurrentRowIndex, 0] = false; //else if (_dg[_dg.CurrentRowIndex, 0].ToString() == "False") // _dg[_dg.CurrentRowIndex, 0] = true; //_dg.Select(_hti.Row); } //else if (_htt == DataGrid.HitTestType.Cell && _dg.CurrentCell.ColumnNumber != 0) //{ // _dg.CurrentCell = new DataGridCell(_hti.Row, _hti.Column); // _dg.Select(_hti.Row); //} } } catch {} }
internal HitTestInfo() { this.type = DataGridViewHitTestType.None; this.typeInternal = DataGridViewHitTestTypeInternal.None; //this.edge = DataGridViewHitTestTypeCloseEdge.None; this.row = this.col = -1; this.rowStart = this.colStart = -1; this.adjacentRow = this.adjacentCol = -1; }
internal HitTestInfo() { _type = DataGridViewHitTestType.None; _typeInternal = DataGridViewHitTestTypeInternal.None; //this.edge = DataGridViewHitTestTypeCloseEdge.None; _row = _col = -1; _rowStart = _colStart = -1; _adjacentRow = _adjacentCol = -1; }
protected override void OnMouseDown(MouseEventArgs e) { try { base.OnMouseDown(e); hitTestInfo = this.HitTest(e.X, e.Y); DataGridViewHitTestType hitTestType = hitTestInfo.Type; if (this.Rows.Count < 1) { if (this.ContextMenuStrip != null) { this.ContextMenuStrip = null; } return; } //If user clicks on blank space below grid, then remove the context menu if (hitTestInfo.Type == DataGridViewHitTestType.None || hitTestInfo.ColumnIndex != 1 || hitTestInfo.RowIndex == -1) { this.ContextMenuStrip = null; return; } if (e.Button == MouseButtons.Right) { this.Rows[hitTestInfo.RowIndex].Selected = true; if (hitTestType == DataGridViewHitTestType.Cell) { if (this.ContextMenuStrip == null) { BuildContextMenu(); } this.ContextMenuStrip = m_deleteContextMenuStrip; } } } catch (Exception oEx) { LoggingHelper.ShowMessage(oEx); } }
void m_deleteContextMenuStrip_Opening(object sender, CancelEventArgs e) { ContextItemClickedEventArg arg = new ContextItemClickedEventArg(); arg.CancelEventArguments = e; DataGridViewHitTestType hitTestType = hitTestInfo.Type; if (hitTestType == DataGridViewHitTestType.Cell) { arg.Data = this;//.Rows[hitTestInfo.RowIndex]; } if (OnContextMenuOpening != null) { OnContextMenuOpening(sender, arg); } }
/// <summary> /// Builds the context menu if is null /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dbDataGridView_MouseDown(object sender, MouseEventArgs e) { try { DataGridView.HitTestInfo hitTestInfo = dbDataGridView.HitTest(e.X, e.Y); DataGridViewHitTestType hitTestType = hitTestInfo.Type; if (hitTestType == DataGridViewHitTestType.Cell) { if (dbDataGridView.ContextMenuStrip == null) { dbDataGridView.BuildRowContextMenu(); } } } catch (Exception oEx) { LoggingHelper.ShowMessage(oEx); } }
internal HitTestInfo (int columnIndex, int columnX, int rowIndex, int rowY, DataGridViewHitTestType type) { this.columnIndex = columnIndex; this.columnX = columnX; this.rowIndex = rowIndex; this.rowY = rowY; this.type = type; }