private void DataGrid_MouseUp(object sender, MouseEventArgs e) { DataGrid.HitTestInfo info = this.DataGridTableStyle.DataGrid.HitTest(e.X, e.Y); if (!this.m_depressedBounds.Equals(Rectangle.Empty)) { Rectangle cellBounds = this.DataGridTableStyle.DataGrid.GetCellBounds(info.Row, info.Column); if (this.m_depressedBounds.Equals(cellBounds)) { Rectangle rectangle3 = new Rectangle(e.X, e.Y, 1, 1); Rectangle controlBounds = this.GetControlBounds(cellBounds); if (rectangle3.IntersectsWith(controlBounds)) { object objectValue = RuntimeHelpers.GetObjectValue(this.DataGridTableStyle.DataGrid.DataSource); string dataMember = this.DataGridTableStyle.DataGrid.DataMember; CurrencyManager source = (CurrencyManager)this.DataGridTableStyle.DataGrid.BindingContext[RuntimeHelpers.GetObjectValue(objectValue), dataMember]; string str = StringType.FromObject(this.GetColumnValueAtRow(source, info.Row)); if (str.ToLower().Equals("start")) { str = "Stop"; } else if (str.ToLower().Equals("stop")) { str = "Start"; } this.SetColumnValueAtRow(source, info.Row, str); if (this.ClickEvent != null) { this.ClickEvent(new ButtonColumnEventArgs(info.Row, info.Column, str)); } } } this.m_depressedBounds = Rectangle.Empty; this.DataGridTableStyle.DataGrid.Invalidate(cellBounds); } }
public void HandleMouseDown(object sender, MouseEventArgs e) { DataGrid dg = this.DataGridTableStyle.DataGrid; DataGrid.HitTestInfo hti = dg.HitTest(new Point(e.X, e.Y)); bool isClickInCell = (hti.Column == this._columnNum && hti.Row > -1); Rectangle rect = new Rectangle(0, 0, 0, 0); if (isClickInCell) { rect = dg.GetCellBounds(hti.Row, hti.Column); isClickInCell = (e.X > rect.Right - this._button.Width); } if (isClickInCell) { //Console.WriteLine("HandleMouseDown " + hti.Row.ToString()); Graphics g = Graphics.FromHwnd(dg.Handle); //g.DrawImage(this._buttonPressed, rect.Right - this._buttonPressed.Width, rect.Y); DrawButton(g, _buttonPressed, rect, hti.Row); g.Dispose(); _pressedRow = hti.Row; } }
/// <summary> /// 鼠标移动至网格按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void HandleMouseUp(object sender, MouseEventArgs e) { DataGrid dg = this.DataGridTableStyle.DataGrid; DataGrid.HitTestInfo hti = dg.HitTest(new Point(e.X, e.Y)); bool isClickInCell = (hti.Column == this._columnNum && hti.Row > -1); _pressedRow = -1; Rectangle rect = new Rectangle(0, 0, 0, 0); if (isClickInCell) { rect = dg.GetCellBounds(hti.Row, hti.Column); isClickInCell = (e.X > rect.Right - this._buttonFace.Width); } if (isClickInCell) { Graphics g = Graphics.FromHwnd(dg.Handle); // g.DrawImage(this._buttonFace, rect.Right - this._buttonFace.Width, rect.Y); DrawButton(g, this._buttonFace, rect, hti.Row); g.Dispose(); if (CellButtonClicked != null) { CellButtonClicked(this, new DataGridCellButtonClickEventArgs(hti.Row, hti.Column)); } } }
//----- public void Grid_Click(object sender, System.Windows.Forms.MouseEventArgs e) { DataGrid.HitTestInfo hti = grid.HitTest(e.X, e.Y); if (hti.Type == DataGrid.HitTestType.Cell) { row = hti.Row; } }
void pg_MouseUp(object sender, MouseEventArgs e) { System.Drawing.Point point = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = pg.HitTest(point); if (hti.Type == DataGrid.HitTestType.Cell) { pg.Select(hti.Row); } }
private void LocalMouseDown(MouseEventArgs e) { System.Drawing.Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = this.HitTest(pt); if (hti.Type == DataGrid.HitTestType.Cell) { SelectRow(hti.Row); SetFullRowKeyValue(); } }
//DataGrid Mouse Down private void C_DataGrid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { HideCombo(); DataGrid.HitTestInfo Hti = this.C_DataGrid.HitTest(e.X, e.Y); if (Hti.Row >= 0 && Hti.Column >= 1) { ShowCombo(Hti.Row, Hti.Column); } }
private void m_itemsGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { DataGrid.HitTestInfo info = m_itemsGrid.HitTest(e.X, e.Y); if (info != null && info.Row >= 0) { m_itemsGrid.Select(info.Row); DataRow row = m_dataTable.Rows[info.Row]; m_selectedItem = m_tableMap[row["Item Number"].ToString()]; } }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { // FIX: The context menu shows before the underlying verse is selected Point ptGridLocationScreen = g.PointToScreen(new Point(0, 0)); Point ptMouseLocation = Control.MousePosition; ptMouseLocation.X -= ptGridLocationScreen.X; ptMouseLocation.Y -= ptGridLocationScreen.Y; DataGrid.HitTestInfo hti = g.HitTest(ptMouseLocation); g.CurrentCell = new DataGridCell(hti.Row, hti.Column); }
private void Grid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = ((DataGrid)sender).HitTest(pt); if (hti.Type == DataGrid.HitTestType.Cell) { ((DataGrid)sender).CurrentCell = new DataGridCell(hti.Row, hti.Column); ((DataGrid)sender).Select(hti.Row); } }
private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { DataGrid myGrid = (DataGrid)sender; DataGrid.HitTestInfo hti = myGrid.HitTest(e.X, e.Y); if (e.Button == MouseButtons.Right) { if (hti.Type == DataGrid.HitTestType.RowHeader) { CreatePopUpMenu(sender, e); } } }
private void Grid_MouseUp(object sender, MouseEventArgs e) { // Create a HitTestInfo object using the HitTest method. // Get the DataGrid by casting sender. DataGrid myGrid = (DataGrid)sender; DataGrid.HitTestInfo myHitInfo = myGrid.HitTest(e.X, e.Y); Console.WriteLine(myHitInfo); Console.WriteLine(myHitInfo.Type); Console.WriteLine(myHitInfo.Row); Console.WriteLine(myHitInfo.Column); }
private void dgEntries_OnMouseDown(Object sender, MouseEventArgs e) { DataGrid.HitTestInfo hi = dgEntries.HitTest(e.X, e.Y); // By default, the first click on a boolean column sets it into edit // mode, rather than toggling the value. This function overrides the // mousedown behavior to instead cause that to happen for just that // column. if ((hi.Column == 0) && (hi.Row >= 0)) { dtValues.Rows[hi.Row]["X"] = !((bool)dtValues.Rows[hi.Row]["X"]); } }
private void dataGrid1_Click(object sender, System.EventArgs e) { System.Drawing.Point pt = this.dataGrid1.PointToClient(Control.MousePosition); DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(pt); BindingManagerBase bmb = this.BindingContext[this.dataGrid1.DataSource, this.dataGrid1.DataMember]; if (afterCurrentCellChanged && hti.Row < bmb.Count && hti.Type == DataGrid.HitTestType.Cell && hti.Column == checkCol) { this.dataGrid1[hti.Row, checkCol] = !(bool)this.dataGrid1[hti.Row, checkCol]; RefreshRow(hti.Row); } afterCurrentCellChanged = false; }
void ig_MouseUp(object sender, MouseEventArgs e) { System.Drawing.Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = ig.HitTest(pt); if (hti.Type == DataGrid.HitTestType.Cell) { ig.CurrentCell = new System.Windows.Forms.DataGridCell(hti.Row, hti.Column); ig.Select(hti.Row); if (dg.VisibleRowCount < hti.Row) { dg.Select(hti.Row); } } }
void dg_MouseUp(object sender, MouseEventArgs e) { System.Drawing.Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = dg.HitTest(pt); if (hti.Type == DataGrid.HitTestType.Cell) { dg.CurrentCell = new System.Windows.Forms.DataGridCell(hti.Row, hti.Column); dg.Select(hti.Row); if (mybox.hasIndicators && (it.Rows.Count > hti.Row)) { ig.Select(hti.Row); } } }
private void GridClick(object sender, System.EventArgs e, ref DataGrid dgGrid, ref DataGridCell cell, ref TextBox txtBox, ref DataTable oTable, bool bSernr) { if (oTable == null || oTable.Rows.Count <= 0) { return; } try { cell = dgGrid.CurrentCell; if (!bSernr) { if (cell.ColumnNumber != 3) { return; } } // Get click event position (screen) and convert to grid position Point pt = dgGrid.PointToClient(Control.MousePosition); // Get information about click position (type, row/col) DataGrid.HitTestInfo hti = dgGrid.HitTest(pt.X, pt.Y); // Make sure the cell we want to edit is visible this.EnsureRowVisible(dgGrid, cell.RowNumber); // Resize and reposition TextBox to match current cell bounds Rectangle rc = dgGrid.GetCellBounds(cell.RowNumber, cell.ColumnNumber); txtBox.Bounds = this.RectangleToClient(dgGrid.RectangleToScreen(rc)); txtBox.Location = new Point((rc.Location.X + dgGrid.Location.X), (rc.Location.Y + dgGrid.Location.Y)); // Bring the focus to it txtBox.Focus(); //Adjust its value to match current cell value txtBox.Text = dgGrid[cell.RowNumber, cell.ColumnNumber].ToString(); if (txtBox.Text.CompareTo("0") == 0) { txtBox.Text = ""; } // Finally, show the textBox txtBox.Visible = true; } catch (Exception ex) { frmStart.HandleException(ex, true); } }
private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { DataGrid.HitTestInfo hitInfo = dataGrid1.HitTest(e.X, e.Y); if (hitInfo.Type == DataGrid.HitTestType.ColumnHeader || hitInfo.Type == DataGrid.HitTestType.Cell) { _colClickInd = hitInfo.Column; } else { _colClickInd = -1; } } }
private void dgOrderDetails_MouseUp(object sender, MouseEventArgs e) { //gets the row info when a user clicks inside the orders //datagrid. DataGrid dg = (DataGrid)sender; DataGrid.HitTestInfo hitinfo = dg.HitTest(e.X, e.Y); //set the class variable. m_DetailRow = hitinfo.Row; string productName = this.dgOrderDetails[hitinfo.Row, 0].ToString(); //set the class variable. m_ProductName = productName; }
private void DataGrid_MouseDown(object sender, MouseEventArgs e) { DataGrid.HitTestInfo info = this.DataGridTableStyle.DataGrid.HitTest(e.X, e.Y); if ((info.Column != -1) && (((e.Button == MouseButtons.Left) & (info.Type == DataGrid.HitTestType.Cell)) & (this.DataGridTableStyle.GridColumnStyles[info.Column] is DataGridButtonColumn))) { Rectangle rectangle3 = new Rectangle(e.X, e.Y, 1, 1); Rectangle cellBounds = this.DataGridTableStyle.DataGrid.GetCellBounds(info.Row, info.Column); Rectangle controlBounds = this.GetControlBounds(cellBounds); if (rectangle3.IntersectsWith(controlBounds)) { this.m_depressedBounds = cellBounds; this.DataGridTableStyle.DataGrid.Invalidate(cellBounds); } } }
void DataGrid_MouseMove(object sender, MouseEventArgs e) { DataGrid grd = (DataGrid)sender; DataGrid.HitTestInfo hti = grd.HitTest(e.Location); if ((hti.Type == DataGrid.HitTestType.Cell) && (hti.Column == grd.TableStyles[this.DataGridTableStyle.MappingName].GridColumnStyles.IndexOf(this))) //Se la colonna è quella corrente { PlaceControl(grd.GetCellBounds(hti.Row, hti.Column), (CurrencyManager)(grd.BindingContext[grd.DataSource, grd.DataMember]), hti.Row); } else { HideControl(); } }
private void Grid_MouseDown(object sender, MouseEventArgs e) { // Use the DataGrid control's HitTest method with the x and y properties. //I use this event to clear erros in the current row. DataGrid.HitTestInfo GridHit = dg1.HitTest(e.X, e.Y); if (GridHit.Type == DataGrid.HitTestType.Cell) { DataSet DS = (DataSet)dg1.DataSource; if (DS.HasErrors) { DataTable DT = DS.Tables[dg1.DataMember]; DT.Rows[GridHit.Row].ClearErrors(); } } }
/// <summary> /// Highlight the item under the mouse when clicked /// </summary> /// <param name="e">The event arguments</param> protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Left) { DataGrid.HitTestInfo hti = base.HitTest(e.X, e.Y); if (hti.Type == DataGrid.HitTestType.Cell) { base.ResetSelection(); base.CurrentRowIndex = hti.Row; base.Select(hti.Row); } } }
private void dgOrders_MouseUp(object sender, MouseEventArgs e) { //gets the row info when a user clicks inside the orders //datagrid. DataGrid dg = (DataGrid)sender; DataGrid.HitTestInfo hitinfo = dg.HitTest(e.X, e.Y); //get the order id from the datagrid. int OrderID = Convert.ToInt32(this.dgOrders[hitinfo.Row, 0].ToString()); m_OrderID = OrderID; //call the helper method to retrieve the //order details. FillOrderDetails(m_OrderID); }
private void dataGrid1_Click(object sender, System.EventArgs e) { try { Point pt = this.dataGrid1.PointToClient(Control.MousePosition); DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(pt); BindingManagerBase bmb = this.BindingContext[this.dataGrid1.DataSource, this.dataGrid1.DataMember]; if (afterCurrentCellChanged && hti.Row < bmb.Count && hti.Type == DataGrid.HitTestType.Cell && hti.Column == checkCol) { this.dataGrid1[hti.Row, checkCol] = !(bool)this.dataGrid1[hti.Row, checkCol]; RefreshRow(hti.Row); } afterCurrentCellChanged = false; // l_id = long.Parse(dataGrid1[i_row, 3].ToString()); s_makp = dataGrid1[i_row, 4].ToString(); s_mabn = dataGrid1[i_row, 1].ToString(); if (dataGrid1[i_row, 0].ToString().Trim() == "True") { load_dtct(); foreach (DataRow r in dtct.Rows) { r2 = d.getrowbyid(dtton, "ten='" + r["ten"].ToString().Trim() + "' and dang='" + r["dang"].ToString().Trim() + "'"); if (r2 != null) { d.updrec_donthuoc(ds.Tables[0], dataGrid1[i_row, 2].ToString(), l_id, int.Parse(r["stt"].ToString()), long.Parse(r["sttt"].ToString()), int.Parse(r2["mabd"].ToString()), r2["ma"].ToString(), r2["ten"].ToString(), r["tenhc"].ToString(), r2["dang"].ToString(), r["tenkho"].ToString(), r["tennguon"].ToString(), r["tennhomcc"].ToString(), r["handung"].ToString(), r["losx"].ToString(), decimal.Parse(r["soluong"].ToString()), decimal.Parse(r["dongia"].ToString()), decimal.Parse(r["sotien"].ToString()), int.Parse(r["makho"].ToString()), int.Parse(r["manguon"].ToString()), int.Parse(r["nhomcc"].ToString()), decimal.Parse(r2["giaban"].ToString()), decimal.Parse(r2["giamua"].ToString()), Math.Round(decimal.Parse(r["soluong"].ToString()) * decimal.Parse(r2["giaban"].ToString()), 0), false, null); } else { d.updrec_donthuoc(ds.Tables[0], dataGrid1[i_row, 2].ToString(), l_id, int.Parse(r["stt"].ToString()), long.Parse(r["sttt"].ToString()), int.Parse(r["mabd"].ToString()), r["ma"].ToString(), r["ten"].ToString(), r["tenhc"].ToString(), r["dang"].ToString(), r["tenkho"].ToString(), r["tennguon"].ToString(), r["tennhomcc"].ToString(), r["handung"].ToString(), r["losx"].ToString(), decimal.Parse(r["soluong"].ToString()), decimal.Parse(r["dongia"].ToString()), decimal.Parse(r["sotien"].ToString()), int.Parse(r["makho"].ToString()), int.Parse(r["manguon"].ToString()), int.Parse(r["nhomcc"].ToString()), decimal.Parse(r["giaban"].ToString()), decimal.Parse(r["giamua"].ToString()), decimal.Parse(r["sotienban"].ToString()), true, null); } } } else { d.delrec(ds.Tables[0], "id=" + l_id); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void dataGrid2_MouseClick(object sender, MouseEventArgs e) { Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hitInfo = this.dataGrid2.HitTest(pt); if (hitInfo.Type == DataGrid.HitTestType.Cell) { if (this.dataGrid2[hitInfo.Row, hitInfo.Column].ToString().StartsWith("=")) { this.label1.Text = calcEngine.ParseAndComputeFormula(this.dataGrid2[hitInfo.Row, hitInfo.Column].ToString()); } else { this.label1.Text = "Not a Formula Cell"; } } }
/// <summary> /// Select an item if the mouse is clicked on an item in the drop-down /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void dgDropDown_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { DataGrid.HitTestInfo hti = dgDropDown.HitTest(e.X, e.Y); if (hti.Type == DataGrid.HitTestType.Cell) { owner.CommitSelection(hti.Row); } if (owner.DropDownStyle == ComboBoxStyle.Simple) { owner.FocusTextBox(); } } }
/// <summary> /// Highlight the item under the mouse when it moves /// </summary> /// <param name="e">The event arguments</param> protected override void OnMouseMove(MouseEventArgs e) { // We tend to get lots of these even if the mouse doesn't move. It's an OS thing apparently. if (lastMousePos.X != e.X || lastMousePos.Y != e.Y) { if ((!this.IsSimpleStyle && this.MouseTracking) || e.Button == MouseButtons.Left) { lastMousePos = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = base.HitTest(e.X, e.Y); if (hti.Type == DataGrid.HitTestType.Cell) { base.ResetSelection(); base.CurrentRowIndex = hti.Row; base.Select(hti.Row); } else if (hti.Type == DataGrid.HitTestType.None) { int newRow = base.CurrentRowIndex; // Scroll when out of bounds if (e.Y < base.Top && newRow > 0) { newRow--; } else if (e.Y > base.Bottom && newRow < DataGridHelper.RowCount(this) - 1) { newRow++; } if (newRow != base.CurrentRowIndex) { base.ResetSelection(); base.CurrentRowIndex = newRow; base.Select(newRow); } } } base.OnMouseMove(e); } }
private void dgCarroSecador_MouseUp(object sender, MouseEventArgs e) { try { DataGrid.HitTestInfo hitInfo = dgCarroSecador.HitTest(e.X, e.Y); if (hitInfo.Type == DataGrid.HitTestType.Cell) { dgCarroSecador.Select(hitInfo.Row); string sCarro = dgCarroSecador[hitInfo.Row, 0].ToString(); if (!string.IsNullOrEmpty(sCarro)) { frmCarroPendienteSecadorDetalle carroPendienteDetalle = new frmCarroPendienteSecadorDetalle(lu, Convert.ToInt32(sCarro)); carroPendienteDetalle.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error al Seleccionar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }
// Override the OnMouseDown event to select the whole row // when the user clicks anywhere on a row. protected override void OnMouseDown(MouseEventArgs e) { // Get the HitTestInfo to return the row and pass // that value to the IsSelected property of the DataGrid. DataGrid.HitTestInfo hit = this.HitTest(e.X, e.Y); if (hit.Row < 0) { return; } if (this.IsSelected(hit.Row)) { UnSelect(hit.Row); } else { Select(hit.Row); } }