FIX: KeyPad PLUS SIGN (+) and MINUS SIGN (-) Do Not Appear in DataGrid Control with C# (329333)
The information in this article applies to:
- Microsoft .NET Framework SDK 1.0
This article was previously published under Q329333 SYMPTOMS In the Windows Forms DataGrid control, when you use KeyPad
to type PLUS SIGN (+) or MINUS SIGN (-), these symbols do not appear in the
DataGrid control. RESOLUTION To resolve the problem, you must inherit your own datagrid
class from System.Windows.Forms.DataGrid class, and then override the following functions:
The following code demonstrates this resolution: public class OwnDataGrid : System.Windows.Forms.DataGrid
{
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs ke)
{
switch(ke.KeyCode)
{
case Keys.Add :
ke = new KeyEventArgs(ke.Modifiers|Keys.Oemplus);
break;
case Keys.Subtract :
ke = new KeyEventArgs(ke.Modifiers|Keys.OemMinus);
break;
}
base.OnKeyDown(ke);
base.ProcessGridKey(ke);
}
protected override bool ProcessDialogKey(System.Windows.Forms.Keys keyData)
{
switch(keyData)
{
case Keys.Subtract :
return base.ProcessDialogKey(Keys.OemMinus);
case Keys.Add :
return base.ProcessDialogKey(Keys.Oemplus);
default :
return base.ProcessDialogKey(keyData);
}
}
protected override bool ProcessKeyPreview(ref System.Windows.Forms.Message m)
{
int WM_KEYDOWN = 0x100;
if(m.Msg == WM_KEYDOWN)
{
KeyEventArgs ke = new KeyEventArgs((Keys)m.WParam.ToInt32() | ModifierKeys);
switch(ke.KeyCode)
{
case Keys.Add :
ke = new KeyEventArgs(Keys.Oemplus | ModifierKeys);
break;
case Keys.Subtract :
ke = new KeyEventArgs(Keys.OemMinus | ModifierKeys);
break;
}
return base.ProcessGridKey(ke);
}
return base.ProcessKeyPreview(ref m);
}
}
STATUS
This bug was corrected in Microsoft .NET Framework SDK 1.1.
Modification Type: | Major | Last Reviewed: | 4/8/2003 |
---|
Keywords: | kbbug kbfix KB329333 |
---|
|