Solved

Send key strokes to control

Posted on 2014-09-02
1
211 Views
Last Modified: 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.

Thanks
0
Comment
Question by:townsma
1 Comment
 
LVL 6

Accepted Solution

by:
townsma earned 0 total points
ID: 40300325
I have found the solution, turns out, as I half expected, to be really easy.  The controls have the Handle parameter, I just used this handle with the PostMessage method.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question