Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a C sharp application. It contains a MultiLine TextBox. Now I want, when a user press Enter key it jumps to next line instead of different control(that i used in condition). When user press Enter key twice then only it jumps to next control. So i require the if statement.


Need Suggestion
Thanks in advance
Posted
Comments
BillWoodruff 26-Sep-11 7:40am    
Why aren't you using the Tab key to move from Control to Control ?

Look at the AcceptsReturn property in the designer view if your TextBox; or set it to True programmatically.
 
Share this answer
 
Comments
Richard MacCutchan 26-Sep-11 7:23am    
Your question is marked as C# and you asked about the user pressing the Enter key. I don't understand what this VB6 code has to do with any of that.
The default expectation in a multiline textbox is for the enter key go to a new line, not jump to another control.

Pressing enter twice is even more confusing.
 
Share this answer
 
It Doesn't work. Ok if anyone know the VB6 then here's the code as i had done it in VB.

If KeyAscii = 13 Then
If Right(Trim(textBox1.Text), 2) = Chr(13) & Chr(10) Then
KeyAscii = 0
textBox1.Text = Trim(Left(textBox1.Text, Len(textBox1.Text) - 2))
textBox2.SetFocus
End If
Else
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
 
Share this answer
 
Comments
Richard MacCutchan 26-Sep-11 12:10pm    
Please do not post additional information as a Solution. Edit your original question and place the information there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900