469,286 Members | 2,522 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Help with SendKeys

When the user presses "Enter" on my comboBox, I would like for the selector
to go to the next comboBox. Since this is kind of like hitting the "tab"
key I thought I would just enable my KeyDown event for my comboBox with this
code...

SendKeys.Send(Keys.Tab);

This doesn't work. Any ideas why?
Nov 16 '05 #1
7 19026
Nevermind, I found that I can use this code to make it work.

SendKeys.Send("{Tab}");
But I still wouldn't mind seeing any comments - am I doing this efficiently
or is there another way I should be doing this?
Nov 16 '05 #2
Keith,

What I would do is attach an event handler to the combobox for the Key
Up event. When you detect the enter key was pressed, call the
GetNextControl method on the combobox, and it will give the next control in
the tab order. Then, call Focus on that control. I think it is much
cleaner than using SendKeys.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Keith Smith" <ke*********@verizon.net> wrote in message
news:J38Od.23510$uc.8986@trnddc03...
Nevermind, I found that I can use this code to make it work.

SendKeys.Send("{Tab}");
But I still wouldn't mind seeing any comments - am I doing this
efficiently or is there another way I should be doing this?

Nov 16 '05 #3
"Keith Smith" <ke*********@verizon.net> wrote:
[using SendKeys to tab to next control]


A nasty hack indeed! Try this:

this.ProcessTabKey(true);

P.
Nov 16 '05 #4
Paul,

Unfortunately, that won't work, as it only works on container controls,
which the ComboBox is not (there is no such method on that type).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:cu**********@titan.btinternet.com...
"Keith Smith" <ke*********@verizon.net> wrote:
[using SendKeys to tab to next control]


A nasty hack indeed! Try this:

this.ProcessTabKey(true);

P.

Nov 16 '05 #5
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
wrote:
[ProcessTabKey] only works on container
controls, which the ComboBox is not


this.ProcessTabKey(true);
^^^^
But "this" is the Form that contains the ComboBox. It works fine here.

P.
Nov 16 '05 #6
>
What I would do is attach an event handler to the combobox for the Key
Up event. When you detect the enter key was pressed, call the
GetNextControl method on the combobox, and it will give the next control
in the tab order. Then, call Focus on that control. I think it is much
cleaner than using SendKeys.


Should I use KeyUp or KeyDown? or does it matter?
Nov 16 '05 #7
Since it's your app, it's your call. However, you'll find that most
applications have a tendency to user KeyUp. Either way, you should defintely
be using the Focus method in this situation.

"Keith Smith" <ke*********@verizon.net> wrote in message
news:fCdOd.23755$uc.20671@trnddc03...

What I would do is attach an event handler to the combobox for the Key
Up event. When you detect the enter key was pressed, call the
GetNextControl method on the combobox, and it will give the next control
in the tab order. Then, call Focus on that control. I think it is much
cleaner than using SendKeys.


Should I use KeyUp or KeyDown? or does it matter?



Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bryan | last post: by
5 posts views Thread by =?Utf-8?B?U3JpbWFu?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.