using Same Shortcut keys on Different Tabs of a form
-
Hi all, I am developing a Winform appln in C#, which contains multiple tabs.. i want to use same shortcut keys on different tabs for different controls. but i am not able to the same, can any one help ?? Thanks in advance..
-
Hi all, I am developing a Winform appln in C#, which contains multiple tabs.. i want to use same shortcut keys on different tabs for different controls. but i am not able to the same, can any one help ?? Thanks in advance..
Set the Form's
KeyPreview
property totrue
and handle theKeyDown/KeyPress
events. Don't handle the KeyDown/KeyPress events of the tab or the constituent controls. Within the event handler, you can look for specific key combinations and take action based on the active tab. -
Hi all, I am developing a Winform appln in C#, which contains multiple tabs.. i want to use same shortcut keys on different tabs for different controls. but i am not able to the same, can any one help ?? Thanks in advance..
I'd recommend a simple if or case statement (whichever you prefer) to identify the current selected tab.
switch (tabControl.SelectedIndex)
{
case 0:
//do stuff
break;
case 1:
//do some other stuff
break;
}This would work under the assumption that you were using the tab indices to find out what's currently selected. There's also a function that allows you to check the current tab by its name. It'd work in the same respect as the
.SelectedIndex
function, expect you'd be using the tab names rather than the indices. It's the.SelectedTab
function. I hope this was of some help. Happy programming! :)