public static void KeyDelToRemove(KeyEventArgs e, RadButton btnDelete) { if (e.KeyCode == Keys.Delete) { btnDelete.PerformClick(); } }
public static void KeyEnterToSaveChanges(KeyEventArgs e, RadButton btnYes, RadButton btnSave) { if (e.KeyCode == Keys.Enter) { if (!btnYes.Enabled) { btnSave.PerformClick(); } else { btnYes.PerformClick(); } } }
private void frmMain_KeyDown(object sender, KeyEventArgs e) { try { Control control = this.scContainer.Panel2.Controls.Find(ControlName, true).FirstOrDefault(); if (control == null) { return; } RadButton radBtn = null; Button btn = null; Control btncontrol = null; switch (e.KeyCode) { case Keys.F1: btncontrol = FindControl(control, "btnRecord"); radBtn = btncontrol as RadButton; radBtn.PerformClick(); break; case Keys.F2: btncontrol = FindControl(control, "btnChooseProduct"); btn = btncontrol as Button; btn.PerformClick(); SetFocus(control); break; case Keys.F10: btncontrol = FindControl(control, "btnInsert"); btn = btncontrol as Button; btn.PerformClick(); break; case Keys.F11: break; case Keys.F12: break; case Keys.F3: btncontrol = FindControl(control, "btnAddCustomer"); btn = btncontrol as Button; btn.PerformClick(); break; case Keys.F4: break; case Keys.F5: break; case Keys.F6: break; case Keys.F7: break; case Keys.F8: btncontrol = FindControl(control, "btnNew"); btn = btncontrol as Button; btn.PerformClick(); break; case Keys.F9: btncontrol = FindControl(control, "btnDelete"); btn = btncontrol as Button; btn.PerformClick(); break; default: break; } } catch (Exception ex) { _logger.LogError(ex, "The application received an error ", "frmMain", "Sales screen key press"); Helper.ShowMessage("The application received an error \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }