Solved

Send key strokes to control

Posted on 2014-09-02
1
202 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now