Click here to Skip to main content
15,885,921 members
Home / Discussions / C#
   

C#

 
GeneralRe: Target Framework in VS Pin
Kevin Marois13-Aug-15 12:00
professionalKevin Marois13-Aug-15 12:00 
GeneralRe: Target Framework in VS Pin
Bill 100113-Aug-15 12:06
Bill 100113-Aug-15 12:06 
GeneralRe: Target Framework in VS Pin
Kevin Marois13-Aug-15 12:07
professionalKevin Marois13-Aug-15 12:07 
QuestionDragging A Control - Limits Pin
Kevin Marois6-Aug-15 7:24
professionalKevin Marois6-Aug-15 7:24 
AnswerRe: Dragging A Control - Limits Pin
Alan N7-Aug-15 8:07
Alan N7-Aug-15 8:07 
QuestionInterop.COMSVCSLib.DLL - Application Error Pin
cpremesh6-Aug-15 2:58
cpremesh6-Aug-15 2:58 
QuestionExecute keyboard shortcuts through code Pin
Member 108502535-Aug-15 15:18
Member 108502535-Aug-15 15:18 
AnswerRe: Execute keyboard shortcuts through code Pin
OriginalGriff5-Aug-15 22:33
mveOriginalGriff5-Aug-15 22:33 
Load's of 'em, depending on the environment.

For WinForms, it's pretty simple:
The first way is via a menu - each menu item (including ToolStripMenuItem) has a ShortcutKeys property which lets you activate that menu item directly.
The more flexible way is to set the form KeyPreview property to true, and override the ProcessCmdKey method:
C#
/// <summary>
/// Handle Left and right keys.
/// (This effectively gives us Shortcut keys for the Select / Deselect buttons)
/// </summary>
/// <param name="msg"></param>
/// <param name="keyData"></param>
/// <returns></returns>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
    if (!tbFilter.ContainsFocus || (ModifierKeys & Keys.Control) != 0)
        {
        // Only Handle if not in filter textbox, or if Control is used as an override.
        if (keyData == Keys.Left || keyData == (Keys.Left | Keys.Control))
            {
            butDeselectAll.PerformClick();
            return true;
            }
        if (keyData == Keys.Right || keyData == (Keys.Right | Keys.Control))
            {
            butSelectAll.PerformClick();
            return true;
            }
        }
    return base.ProcessCmdKey(ref msg, keyData);
    }

Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: Execute keyboard shortcuts through code Pin
Member 108502536-Aug-15 1:40
Member 108502536-Aug-15 1:40 
GeneralRe: Execute keyboard shortcuts through code Pin
OriginalGriff6-Aug-15 1:43
mveOriginalGriff6-Aug-15 1:43 
GeneralRe: Execute keyboard shortcuts through code Pin
Member 108502536-Aug-15 1:48
Member 108502536-Aug-15 1:48 
GeneralRe: Execute keyboard shortcuts through code Pin
Member 108502536-Aug-15 1:59
Member 108502536-Aug-15 1:59 
GeneralRe: Execute keyboard shortcuts through code Pin
OriginalGriff6-Aug-15 2:11
mveOriginalGriff6-Aug-15 2:11 
GeneralRe: Execute keyboard shortcuts through code Pin
Member 108502536-Aug-15 7:37
Member 108502536-Aug-15 7:37 
GeneralRe: Execute keyboard shortcuts through code Pin
OriginalGriff6-Aug-15 7:59
mveOriginalGriff6-Aug-15 7:59 
QuestionInterview question - adding using A RecursiveAlgorithm Pin
anthonyjames5-Aug-15 12:18
anthonyjames5-Aug-15 12:18 
GeneralRe: Interview question - adding using A RecursiveAlgorithm Pin
PIEBALDconsult5-Aug-15 13:15
mvePIEBALDconsult5-Aug-15 13:15 
GeneralRe: Interview question - adding using A RecursiveAlgorithm Pin
anthonyjames5-Aug-15 13:35
anthonyjames5-Aug-15 13:35 
AnswerRe: Interview question - adding using A RecursiveAlgorithm Pin
Dave Kreskowiak5-Aug-15 13:37
mveDave Kreskowiak5-Aug-15 13:37 
GeneralRe: Interview question - adding using A RecursiveAlgorithm Pin
anthonyjames5-Aug-15 13:43
anthonyjames5-Aug-15 13:43 
GeneralRe: Interview question - adding using A RecursiveAlgorithm Pin
Dave Kreskowiak5-Aug-15 13:56
mveDave Kreskowiak5-Aug-15 13:56 
QuestionIm curious of answers Pin
Jesse Glover5-Aug-15 9:30
Jesse Glover5-Aug-15 9:30 
AnswerRe: Im curious of answers Pin
Ravi Bhavnani5-Aug-15 9:41
professionalRavi Bhavnani5-Aug-15 9:41 
GeneralRe: Im curious of answers Pin
Jesse Glover5-Aug-15 9:43
Jesse Glover5-Aug-15 9:43 
GeneralRe: Im curious of answers Pin
Ravi Bhavnani5-Aug-15 9:49
professionalRavi Bhavnani5-Aug-15 9:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.