F5 is not firing an event when the focus is in Datagrid

G

Guest

I am trying to implement the keyboard functionality in windows forms.
I am overriding the "ProcessDialogKey" method to capture the key strokes.
I could able to capture all the key strokes when the focus is not in the
datagrid.
When the focus is in datagrid i am running into problem:
when i press F5 its not firing any event, all other function keys are firing
an event which i could able to capture using ProcessDialogKey.

If any one has any suggestions can you please let me know.
your help is greatly appreciated.

Thanks
 
C

ClayB [Syncfusion]

Is F5 a shortcut key for some menu item or something of that nature? If so,
it will be caught before ProcessDialogKey is hit. But you might try catching
it in ProcessCmdKey which is hit before ProcessDlgKey.

===================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools
 
G

Guest

Thanks for the reply.

F5 is not a shortcut key.I tried ProcessDialogKey it didn't work

I can capture F5 if the focus is not in the grid.

It seems the issue is specific to F5 , i can capture other function keys
when the focus is in the grid.

Thanks
 
C

ClayB [Syncfusion]

If I use this code for a derived datagrid, both overrides are hit when I
press F5 whether there is an active cell or not. If I add a menu handler
that uses F5 to the form holding this control, only the ProcessCmdKey is
hit. I am using .NET 1.1 and WinXP. Do you have any utilities running on
your system that might make special use of F5?

public class MyDataGrid : DataGrid
{
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(keyData == Keys.F5)
Console.WriteLine("ProcessCmdKey");
return base.ProcessCmdKey (ref msg, keyData);
}

protected override bool ProcessDialogKey(Keys keyData)
{
if(keyData == Keys.F5)
Console.WriteLine("ProcessDialogKey");
return base.ProcessDialogKey (keyData);
}
}

===============================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools
 
G

Guest

Hi Clay,

Thanks, ProcessCmdKey seems to be working. I tried this one before it didn't
work, may be i might have done some thing wrong.

Thanks for your help.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top