471,327 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,327 software developers and data experts.

Multiple Acceptbuttons ?

Hi all,

On my Windows Form, I'm having a SplitContainer control. Each panel
(top & bottom) has a ToolStrip that contains a TextBox and a button.
When a user enters text in the TextBox and presses return, the action
that belongs to the corresponding button should be fired. Therefore, I
could use the AcceptButton of my Windows Form. However, I have two text
boxes on my form (on each ToolStrip). Can I use something like an
AcceptButton for each panel/ToolStrip separately, so the corresponding
code will be executed? Or should I use something like the KeyPress
event and filter out the return key?

Using: VS 2005 C#, Express Edition

Thanks in advance,
Fred

Dec 25 '05 #1
1 1515
Fred wrote:
Hi all,

On my Windows Form, I'm having a SplitContainer control. Each panel
(top & bottom) has a ToolStrip that contains a TextBox and a button.
When a user enters text in the TextBox and presses return, the action
that belongs to the corresponding button should be fired. Therefore, I
could use the AcceptButton of my Windows Form. However, I have two text
boxes on my form (on each ToolStrip). Can I use something like an
AcceptButton for each panel/ToolStrip separately, so the corresponding
code will be executed? Or should I use something like the KeyPress
event and filter out the return key?

Using: VS 2005 C#, Express Edition

Thanks in advance,
Fred

You need to set Form.KeyPreview = true and listen for [Enter] to be
pressed on form level

MuZZy
Dec 25 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Rolf Wester | last post: by
66 posts views Thread by Darren Dale | last post: by
6 posts views Thread by Ben Hallert | last post: by
22 posts views Thread by Matthew Louden | last post: by
9 posts views Thread by Graham | last post: by
4 posts views Thread by Matt Kruse | last post: by
35 posts views Thread by keerthyragavendran | last post: by
reply views Thread by rosydwin | last post: by

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.