How do I do this?

  • Thread starter Thread starter Ned T.
  • Start date Start date
N

Ned T.

Hi,

I an rather new to VB.NET programming and I have the
following problem:

In a Windows Form, I have a User Control.
I have configured the "AcceptButton" property of the form
to a certain button (outside the usercontrol). However I
want something else to be performed when my user
presses "Enter" in a text box inside my usercontrol.
However, the setting of the form seem to override the
KeyDown event handler that I have put on the UserControl
(If I remove the "AcceptButton" property it works fine).

What do I have to do if I want to have both
functionalities (that is when the user does Enter, it
clicks on the button except if is in the textbox where it
does something else).

thanks,

Ned
 
Take a look at the TextBox.AcceptsReturn property. If you set it to True,
it should not trigger the default button.

(In the future, try to use a subject line that summarizes your question --
e.g., "Return in text box without triggering button?" Generic subject lines
that basically say "help me" are not particularly useful, and are easy for
other readers to skip over.)

Hope this helps,
Robert Jacobson
 
Back
Top