I have a single line of text in a Text Box and that is wrapped to many lines, how to count no of wrapped lines in Text Box?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
You could use
String.Split
:If it's a winforms
TextBox
you can also use theLines
property:So it's VB.NET:
Update: Maybe my understanding was wrong and you want to count the "lines" that the UI-element (like the
TextBox
) wrapped your single-line text. Then above doesn't work of course.You could use
Text.GetLineFromCharIndex
:I must admit that i didnt know
GetLineFromCharIndex
before, but it seems to work as expected. I have entered a long single line text and the linecount was 23. After i've reduced the width of the textbox it has changed to 40.