0

I have following code in which I have added one tab control on Main form. and in tab i have included another form. Now i have to implement short cut key(save button like ctrl + s) for included form. can anybody suggest me code..

switch ((sender as TabControl).SelectedIndex)
{
case 0:
       frmVTaskOrderResources.Close();
break;
case 1:
 frmVTaskOrderResources = new TaskResource(frmTaskOrders.tempTOID,    frmTaskOrders.tempStartDt, frmTaskOrders.tempEndDt);
 frmVTaskOrderResources.TopLevel = false;
 frmVTaskOrderResources.Visible = true;
 frmVTaskOrderResources.FormBorderStyle = FormBorderStyle.None;
 frmVTaskOrderResources.Dock = DockStyle.Fill;
 tabControl1.TabPages[1].Controls.Add(frmVTaskOrderResources);

break;
}

if i included following code to form it will work but not in tab control?

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
  if (keyData == (Keys.Control | Keys.F)) {
    MessageBox.Show("What the Ctrl+F?");
    return true;
  }
  return base.ProcessCmdKey(ref msg, keyData);
}
  • [Attribution would be wise](http://stackoverflow.com/a/400325/719186) – LarsTech Jul 24 '13 at 20:26
  • The easiest way i know is to add a menu strip and set the `visiblity` to false and the shortcut key int the Properties window –  Jul 24 '13 at 20:53

1 Answers1

0

You would need to use global hotkeys.

here is a thead that shows how its done: Set global hotkeys using C#

Community
  • 1
  • 1
string.Empty
  • 10,393
  • 4
  • 39
  • 67