How do I tell i

  • Thread starter Thread starter Top Gun
  • Start date Start date
T

Top Gun

Because I am developing a high-speed data entry form that focuses on 10-key,
the users want to have the "+" key on the 10-key pad function as a "tab"
key. I would like to trap this in the textform TextChanged event and do a
SelectNextControl in order to simulate the behavior, but don't know how to
check for the "+" key.

Does anyone know how to do this?

Example:

private void txtTest1_TextChanged(object sender, System.EventArgs e)
{
// Want to test for "+" key pressed here.
}
 
You can do it with the KeyDown event

public void txtTest1_KeyDown(object sender, System.KeyEventArgs e)
{
if(e.KeyData == Keys.Add)
{
// take whatever action, it would the numpad +
// the regular + is Keys.OemPlus I think
}
}
 
Hi,

You will have to create a new class derived from the current control you
are using , this is needed in order to change the key readed, then you would
do something like:

public class FastEntryControl : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if ( (char)'+' == e.KeyChar )
//Create a new KeyPressEventArgs with the new key
base.OnKeyPress( new KeyPressEventArgs ( '\t\ );
else
base.OnKeyPress( e);
}


Cheers,
 
This works, however it is typing a "+" into my textbox, which is not desired
behavior. Is there any way to prevent this and JUST do the tab?
 
Back
Top