1
votes

I'm trying to create a virtual NumPad in my form. When the user clicks any of the numpad buttons, the corresponding number should be sent to the currently focused TextBox (or any other text control).

Simulating keystrokes aside, how can I prevent the numpad button, which is inside a numpad control, from stealing focus from the already focused TextBox?

I've tried googling and searching SO but didn't find anything that helped me.

2
Just return the focus to the "text" control after the numpad event has firedJosef Van Zyl
@Josefvz What if I don't know which control had focus before the button was pressed?OMGKurtNilsen
Then i would suggest looking at the linked question, that should solve your problemJosef Van Zyl

2 Answers

1
votes

Add this line in click event of Numpad button.

this.ActiveControl = YourTextboxID;
0
votes
SetStyle(ControlStyles.Selectable, false);