By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,146 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,146 IT Pros & Developers. It's quick & easy.

Help overriding key combination on datagrid

P: n/a
I'm tring to override the combination all the combination like this one Ctrl
+ Shift + [another key]. I just can't catch it... I have already done this
for ctrl + [any other key] or Shift + [any other key] but for both at same
timeI can't do it....

Can someone tell me how to do it
Here is an example of how I am doing this:
if ((msg.Msg == WM_KEYDOWN) && (keyCode == Keys.Down))
{
if (Control.ModifierKeys == Keys.Shift)
{
return true;
}
}
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Diago,
I would create a control that inherits from DataGrid then override the
ProcessCmdKey method to catch your key combination. The keyData field is a
logical ORing of all currently pressed keys, so an example of how to catch a
Ctrl + Shift + P key combination pressed by the user is given below:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
//Want to catch ctrl + shift + P
Keys keyCombination = Keys.Control | Keys.Shift | Keys.P;

if ((keyData & keyCombination) == keyCombination)
{
//do whatever you want to do.
}

return false;
}

Hope that helps
Mark R Dawson
http://www.markdawson.org

"Diogo Alves - Software Developer" wrote:
I'm tring to override the combination all the combination like this one Ctrl
+ Shift + [another key]. I just can't catch it... I have already done this
for ctrl + [any other key] or Shift + [any other key] but for both at same
timeI can't do it....

Can someone tell me how to do it
Here is an example of how I am doing this:
if ((msg.Msg == WM_KEYDOWN) && (keyCode == Keys.Down))
{
if (Control.ModifierKeys == Keys.Shift)
{
return true;
}
}

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.