Multiple Acceptbuttons ?

F

Fred

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
 
M

MuZZy

Fred said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top