Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a multiline textbox in my form , i want to go to next line by press a key like Enter key.
how to code in KeyDown event for this choice??
Enviroment.newLine dosent work
\r\n dosent work
maybe my code grammer is false ?
is another way for this ?
Posted
Comments
AmitGajjar 22-Aug-12 0:39am    
Why Enter key doen't work for you ?
daghune 22-Aug-12 1:06am    
my code is:
private void textBox3_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
textBox3.Text += Environment.NewLine;
}
}
AmitGajjar 22-Aug-12 1:15am    
each key have it's own ASCII code. you can convert compare that instead of Keys.Enter to solve your issue.
daghune 22-Aug-12 1:46am    
How in Code?
Sergey Alexandrovich Kryukov 22-Aug-12 2:05am    
Not true, sorry. Keys are of different type. Key presses have nothing to do with ASCII. Each key has scan code, it is translated to Keys, still before characters. Then characters comes into play, only for some keys/combinations...
--SA

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