473,545 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generating or simulating key events sent to control on form

Hi Everyone,

Is there a way of generating a keyboard character event and sending it to a
control on a form? For example, if I have a menu item called "Delete", I
would like to send a DEL character event to the currently active control on
the form.

Thanks.
Feb 17 '06 #1
4 1375
Sorry, I forgot to mention that this is for VB.NET 2003.

- Ivan

"Bill J" <Bi***@newsgrou ps.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Everyone,

Is there a way of generating a keyboard character event and sending it to a
control on a form? For example, if I have a menu item called "Delete", I
would like to send a DEL character event to the currently active control on
the form.

Thanks.

Feb 17 '06 #2
Hi Ivan,
Is there a way of generating a keyboard character event
and sending it to a control on a form?


Have you tried the System.Windows. Forms.SendKeys class?

I suggest you can set the focus to the target control first, then call the
System.Windows. Forms.SendKeys. Send method to send the keystroke, such as:

Control1.Focus( )
System.Windows. Forms.SendKeys. Send("{DEL}")

Please refer to the following MSDN documentation for the details:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwind owsformssendkey sclasstopic.asp
Thanks!

Best regards,

Gary Chang
Microsoft Community Support
=============== =============== =============== =========
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
=============== =============== =============== =========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
=============== =============== =============== =========
This posting is provided "AS IS" with no warranties, and confers no rights.
=============== =============== =============== =========

Feb 17 '06 #3
Hi Gary,

Thank you very much. It works like a charm. Cut, copy, paste also work
based on the control key sequences (eg "^C" for copy). However, I am not
able to get Select All to work. The "^A" sequence does not have any effect.
Is there a special command for this in a simple edit control?
""Gary Chang[MSFT]"" <v-******@online.m icrosoft.com> wrote in message
news:0C******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi Ivan,
Is there a way of generating a keyboard character event
and sending it to a control on a form?


Have you tried the System.Windows. Forms.SendKeys class?

I suggest you can set the focus to the target control first, then call the
System.Windows. Forms.SendKeys. Send method to send the keystroke, such as:

Control1.Focus( )
System.Windows. Forms.SendKeys. Send("{DEL}")

Please refer to the following MSDN documentation for the details:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwind owsformssendkey sclasstopic.asp
Thanks!

Best regards,

Gary Chang
Microsoft Community Support
=============== =============== =============== =========
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
=============== =============== =============== =========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
=============== =============== =============== =========
This posting is provided "AS IS" with no warranties, and confers no rights.
=============== =============== =============== =========
Feb 17 '06 #4
Hi Bill,

I think this is because the TextBox control doesn't have a shortcut for the
Select All operation It doesn't work when you press Ctrl+A on a textbox
control directly neither.

I suggest you can use the SelectAll() method of the textbox control instead:

TextBox1.Select All()
Thanks!

Best regards,

Gary Chang
Microsoft Community Support
=============== =============== =============== =========
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
=============== =============== =============== =========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
=============== =============== =============== =========
This posting is provided "AS IS" with no warranties, and confers no rights.
=============== =============== =============== =========

Feb 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
395
by: jimif_fr | last post by:
How is it possible to simulate the keyboard entries (and the mouse events) of one program, from another program. The first program is not written for this purpose and is a not aware of the simulation.
47
7568
by: Lauren Quantrell | last post by:
I have constructed the following code that simulates the common rollover effect when moving the mouse over a label (this example makes the label bold.) I'm wondering if anyone has come up with a better solution. lq 'start code:
6
7014
by: bwahahahaha | last post by:
How can I inject the MouseMove events to move the mouse programatically in C#, or is this not possible and I have to drop to Win32 for this?
2
1446
by: Liz - Newbie | last post by:
I need to generate an event in a user defined control when I have changed a variable, so that I can pick it up in my main form and take it from there. Can someone explain the SIMPLEST way of doing this. Liz (newbie to OO)
7
1320
by: a ghost1207 | last post by:
Hi all, I am trying to figure this out, but I can't: I create a form, then another form (which I call from the first), then add an event handler for KeyDown messages in the second form and finally add another event handler for KeyDown messages in the first form. I end up getting the events when the second form is open and nothing with the...
12
2770
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown when menu items are clicked.Besides these i would like to put a custom status bar. Any error message encountered in any of the webpage will be...
20
10788
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of either an option button plus two text fields or a checkbox plus two text fields Am wanting to save the user entries into an underlying table. Tag...
16
3521
by: akameswaran | last post by:
Ok, this is really irritating me. I'm sure there are different ways of doing this - I'm interested in the algo, not the practical solution, I'm more trying to play with iterators and recursion. I want to create a program that generates every possible combination of a set of a n dice, with s sides. so I started with an iterator class...
5
4367
by: Richard Maher | last post by:
Hi, Here I mean "User" in the Programmer or Javascript sense. I merely wish to programmatically trigger an Event. It would be absolutely fantastic if there was a (Form level?) ONUSEREVENT() and a setEvent() function but, in the absence of this, is it not possible to use DOM to change an object's properties resulting in a state-change event?...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.