Send key strokes to control
Posted on 2014-09-02
I have a WinForm laid out as a keyboard. This form gets shown as a dialog when I Enter certain controls on a another form.
I pass references to both the parent form, and the actual control to the keyboard form, with the intention of programatically send key stroke to the control.
I tried using the contro.SelectedText = "x" approach, and that works great for the text or pure integer controls, but it doesn't work on decimal or currency type fields.
So recently I have been looking at SendKeys.Send(), and even PostMessage(), but in both cases, whilst the code appears to run, nothing appears in the control.
Now I would have thought it would be pretty easy to send keystrokes to a control, when you already have a reference to that control, but this problem eludes me.
Can anyone suggest a simple foolproof way to do this.