[IronPython] How to capture a 'Carriage Return' in a windows form ?

Brannon Jones brannon at iterator.net
Wed Jul 1 19:08:31 CEST 2009


Set the AcceptsReturn property on the TextBox:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.acceptsreturn.aspx

<http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.acceptsreturn.aspx>You'll
also need to set the AcceptButton property on the Form:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.acceptbutton.aspx

<http://msdn.microsoft.com/en-us/library/system.windows.forms.form.acceptbutton.aspx>
Brannon

On Wed, Jul 1, 2009 at 07:41, Brian Curtin <brian.curtin at gmail.com> wrote:

> On Wed, Jul 1, 2009 at 09:31, Sivaguru Perambalam <itssivaguru at gmail.com>wrote:
>
>> Hello ,
>>
>> I have a Windows form with a text box and a button.
>> What I want to implement it, when the user hits the 'Enter' key in the
>> text box, the function that's linked to the ButtonClick event has to be
>> invoked.
>> Please give me like a code example of how this could be done in a simpler
>> way, since I am not familiar with Forms or GUI stuff .
>>
>> Thanks !
>>
>
> You could check out the OnKeyDown event:
> http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onkeydown(loband).aspx.
> The C# example pretty easily translates to IronPython, so you could follow
> that and check when the KeyEventArgs.KeyCode is equal to Keys.Return, then
> call your ButtonClick method.
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090701/92bacfdf/attachment.html>


More information about the Ironpython-users mailing list