Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i have made a RUN TIME TextBox control in a WPF application and the text source is from a database(its an article)

the problem is that the text box isn't in "word wrap" format so it goes to next line when it reaches to an new paragraph, but i want to make it like Ms word, that when the text reaches at the end of the textbox-width it goes to the next line (without enter)

how do i do that?
Posted

Look at how it should be in your case:
XML
<TextBox AcceptsReturn="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" />


Actually, AcceptReturn can be either true or false, depending on your requirements, Auto value for scroll bars is only a recommendation (horizontal bar will be never shown in case of wrapping), only TextWrapping is critical to satisfy your requirement.

Use can also assign AcceptsReturn, TextWrapping and other properties in C# code, of course.

—SA
 
Share this answer
 
v3
Comments
Espen Harlinn 7-Jul-11 17:30pm    
Yes, my 5
Sergey Alexandrovich Kryukov 7-Jul-11 17:32pm    
Thank you, Espen.
--SA
M-Shaf 9-Jul-11 2:48am    
Thank's
It Worked
Sergey Alexandrovich Kryukov 9-Jul-11 12:30pm    
You're welcome.
Good luck, call back,
--SA
Have you tried setting the Multiline property to true?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Jul-11 17:08pm    
Sorry, there is no such property. This is ***not*** System.Windows.Forms.Text box, but System.Windows.Controls.TextBox.
--SA
Sergey Alexandrovich Kryukov 7-Jul-11 17:12pm    
I posted a correct answer for WPF, please see.
--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