private void txtControl_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { #region txtSearch if (sender == txtSearch) { if (e.KeyCode == Keys.Tab) { Grid.Focus(); return; } if (e.KeyCode == Keys.Enter) { if (Grid.Rows.Count > 0) { UltraGridRow aUGRow = Grid.Rows[0]; Grid.ActiveRow = aUGRow; if (Grid.ActiveRow != null) { SelectedID = Grid.ActiveRow.Cells["Teacher"].Text; CustomerID = Grid.ActiveRow.Cells["CustomerID"].Text; } this.Close(); } else { this.Close(); } return; } } #endregion #region Grid if (sender == Grid) { if (e.KeyCode == Keys.Tab) { txtSearch.Focus(); return; } if (e.KeyCode == Keys.Enter) { if (Grid.Rows.Count > 0) { if (Grid.ActiveRow != null) { SelectedID = Grid.ActiveRow.Cells["Teacher"].Text; CustomerID = Grid.ActiveRow.Cells["CustomerID"].Text; } this.Close(); } return; } } #endregion #region Default Option //Default option switch (e.KeyCode) { case Keys.Up: if (Grid.Focused) { if (Grid.Rows.Count == 0) { } else if (Grid.ActiveRow == Grid.Rows[0]) { txtSearch.Focus(); } else { Grid.PerformAction(UltraGridAction.AboveCell, false, false); } } e.Handled = true; break; case Keys.Down: if (txtSearch.Focused && Grid.Rows.Count > 0) { Grid.Focus(); } Grid.PerformAction(UltraGridAction.BelowCell, false, false); e.Handled = true; break; case Keys.Right: //UltraGrid1.PerformAction(ExitEditMode, False, False) Grid.PerformAction(UltraGridAction.NextCellByTab, false, false); e.Handled = true; //UltraGrid1.PerformAction(EnterEditMode, False, False) break; case Keys.Left: //UltraGrid1.PerformAction(ExitEditMode, False, False) Grid.PerformAction(UltraGridAction.PrevCellByTab, false, false); e.Handled = true; //UltraGrid1.PerformAction(EnterEditMode, False, False) break; case Keys.Enter: DataGrid_MouseUp(null, null); e.Handled = true; break; } #endregion }
private void txtControl_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { #region txtSearch if (sender == txtSearch) { if (e.KeyCode == Keys.Tab) { MessageBox.Show("Tab"); Grid.Focus(); return; } } #endregion #region Grid if (sender == Grid) { if (e.KeyCode == Keys.Tab) { txtSearch.Focus(); return; } } #endregion #region Default Option //Default option switch (e.KeyCode) { case Keys.Up: if (Grid.Focused) { if (Grid.Rows.Count == 0) { } else if (Grid.ActiveRow == Grid.Rows[0]) { txtSearch.Focus(); } else { Grid.PerformAction(UltraGridAction.AboveCell, false, false); } } e.Handled = true; break; case Keys.Down: if (txtSearch.Focused && Grid.Rows.Count > 0) { Grid.Focus(); } Grid.PerformAction(UltraGridAction.BelowCell, false, false); e.Handled = true; break; case Keys.Right: //UltraGrid1.PerformAction(ExitEditMode, False, False) Grid.PerformAction(UltraGridAction.NextCellByTab, false, false); e.Handled = true; //UltraGrid1.PerformAction(EnterEditMode, False, False) break; case Keys.Left: //UltraGrid1.PerformAction(ExitEditMode, False, False) Grid.PerformAction(UltraGridAction.PrevCellByTab, false, false); e.Handled = true; //UltraGrid1.PerformAction(EnterEditMode, False, False) break; case Keys.Enter: DataGrid_MouseUp(null, null); e.Handled = true; break; } #endregion }
private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if (sender == txtSearch) { if (e.KeyCode == Keys.Tab) { gKits.Focus(); return; } } #region gKits if (sender == gKits) { return; } #endregion #region txtCustomerID if (sender == txtCustomerID) { if (e.KeyCode.ToString() == "F2") { if (oCustomer.View()) { this.txtCustomerID.Text = oCustomer.ID; if (!oCustomer.Find(txtCustomerID.Text)) { this.txtCustomerID.Focus(); return; } this.txtName.Text = oCustomer.Name; gKits.DataSource = oCustomer.ReOrders.GetDataTable(oCustomer); gKits.Focus(); return; } this.txtName.Text = oCustomer.Name; } if (e.KeyCode.ToString() == "Return" || e.KeyCode.ToString() == "Tab") { if (!oCustomer.Find(txtCustomerID.Text)) { this.txtCustomerID.Focus(); return; } this.txtName.Text = oCustomer.Name; gKits.DataSource = oCustomer.ReOrders.GetDataTable(oCustomer); gKits.Focus(); return; } } #endregion #region Default Option //Default option switch (e.KeyCode) { case Keys.Tab: if (!e.Shift) { this.SelectNextControl(this.ActiveControl, true, true, true, true); } break; case Keys.Enter: this.SelectNextControl(this.ActiveControl, true, true, true, true); break; case Keys.Down: this.SelectNextControl(this.ActiveControl, true, true, true, true); break; case Keys.Up: this.SelectNextControl(this.ActiveControl, false, true, true, true); break; case Keys.F3: deleteOrder(); break; case Keys.PageDown: break; //case Keys.<some key>: // ......; // break; } #endregion }