On clicking Enter Key in a Multiline TextBox - Should go to next line

I am working on VS 2005 / Vb.Net -

I have a  multi line TextBox
On clicking Enter key inside the Texbox, i need to go to new line or next line ..

But now it goes directly to Save Command - Saving to Database ..!

Private Sub txtNotes1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtNotes1.KeyDown
            If (e.KeyCode = Keys.Enter) Then
                If txtNotes1.Multiline = True AndAlso txtNotes1.AcceptsReturn = True Then
                    txtNotes1.Text &= System.Environment.NewLine
                    e.Handled = True
                End If
                txtNotes1.SelectionStart = txtNotes1.Text.Length
            End If
        End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does your event fire ? If it does not I'd consider using KeyPressed event.
chokkaStudentAuthor Commented:

I have method name SaveCoPay() which is written on button click event.

Now when ever i press Enter Key inside the Textbox .. it goes directly to this event ..!

Protected Overrides Sub cmdSave_Click(ByVal sender As Object, ByVal e As System.EventArgs)


End Sub

That's wierd, isn't the form inherited from another one ? So this functionality on Enter key is written there ?
Mike TomlinsonMiddle School Assistant TeacherCommented:
You've set the AcceptButton() Property of the FORM to your "cmdSave" Button and this is trapping the Enter key.  You need to unset that button as the AcceptButton for the MultiLine TextBox to work properly...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chokkaStudentAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.