Re: Textbox line property
- From: "Armin Zingler" <az.nospam@xxxxxxxxxx>
- Date: Fri, 17 Jul 2009 20:19:11 +0200
Miro wrote:
I am looking for something similar to the textbox "lines" property...
(
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.lines(VS.85).aspx
)
but what I am looking to do is to be able to grab each "Line" out of a
multiline as it is "displayed".
Example:
Create a textbox multiline option true, and set it to like 25
characters wide...
This whole line will print on one line <enter key>
This line will print on the other line but as i am continueing to
type it will automatically word wrap it on the screen.
That second line, I want to grab as 2 lines out.
Basically if you have a "super long string" and would like to parse
it out to word wrap just like the multiline text box.
Or do i have to write my own little for next loop to grab the words
and parse my new string?
I do not have a problem in setting my texbox.enabled = false, throw
my long string into it, as long as i can loop through each line and
pull it out 1 by one. ( as it is displayed ).
Well, what you have after displaying a String are not lines but an image. So you can only get the size (in pixels) of the text, for example by using graphics.measurestring and derive the number of lines from the height. You'd have to immitate the Textbox' behavior exactly. However, then you only have the number of lines but you don't have a list of strings as displayed in the textbox. Therefore the approach you mentioned is probably the only way to go; maybe optimized by using a binary approach (like the binary search algorithm).
Armin
.
- Follow-Ups:
- Re: Textbox line property
- From: Mike Williams
- Re: Textbox line property
- References:
- Textbox line property
- From: Miro
- Textbox line property
- Prev by Date: Re: How Do I Find MyApplication Events?
- Next by Date: Re: Object initialized in a try-catch
- Previous by thread: Textbox line property
- Next by thread: Re: Textbox line property
- Index(es):
Relevant Pages
|