tags:

views:

78

answers:

2

how can I press "Enter" on c# and WPF without pressing enter on hardware keyboard ?

A: 

Assuming that you're working with WindowsForms... by using SendKeys.Send("{ENTER}");

See this documentation here as well: http://msdn.microsoft.com/de-de/library/system.windows.forms.sendkeys.send.aspx

Christian
I am working on WPF !!!
salamonti
@salamonti, this important information should have been stated either in your question or tags.
Darin Dimitrov
@salamonti: You didn't say so in your question, no need to act up.
Christian
+2  A: 

Ah, so you're saying SendKeys is unavailable?

Check these threads, on the MSDN forums: http://social.expression.microsoft.com/Forums/en-US/wpf/thread/915cb53a-704b-4047-8fd0-e7c5a8feae5e/

http://social.msdn.microsoft.com/forums/en-US/wpf/thread/6557c1eb-6eb5-4f4a-84d6-4ae4fb5b9dab/

Sounds like you can trap KeyDown events, but that's not exactly what you want...

Oh, wait! Check this SO thread: http://stackoverflow.com/questions/1645815/how-can-i-programmatically-generate-keypress-events-in-c

Beyond that, How and why do you need to send "Enter" without a keyboard press? There may be a different solution lurking there. :)

djacobson
TO enable to write on autocompletebox because Focus() didn't work it just choose the control but can't enable to write untill I press enter or tab !
salamonti
Ok. So you're programmatically Focusing on the autocompletebox, and you want to send an Enter press so that (a) the user can just start typing without having to focus on the field themselves, or (b) you can programmatically "type" in the box? Are you trying to achieve (a) or (b)?
djacobson