I have a method in response to a KeyUp event of a control.
{
}
In oder to get the string of the key pressed you have to do something like this:
string _keyPressed = ((char)e.KeyValue).ToString();
But, this is not working all the time. For example if you press "+" you will get in _keyPress a value like ">>".
The solution is to use KeyPress event. This has a KeyPressEventArgs, that has a property KeyChar. Now, the code looks like:
void m_control_KeyPress(object sender, KeyPressEventArgs e)
{
string _keyPressed = e.KeyChar.ToString()
}
But, this is not working all the time. For example if you press "+" you will get in _keyPress a value like ">>".
The solution is to use KeyPress event. This has a KeyPressEventArgs, that has a property KeyChar. Now, the code looks like:
void m_control_KeyPress(object sender, KeyPressEventArgs e)
{
string _keyPressed = e.KeyChar.ToString()
}
Niciun comentariu:
Trimiteți un comentariu