Re: Textbox line property

Tech-Archive recommends: Speed Up your PC by fixing your registry



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

.



Relevant Pages

  • Re: Persias playing with the string!
    ... >> Persia bats the string around and even though some evil person front ... >> declawed her she manages to grab the string with her paw. ... > using string - even thick ones like shoe/boot laces! ... > turned the ceiling fan on and sat back and LHAO while watching Smokey ...
    (rec.pets.cats.anecdotes)
  • Re: Persias playing with the string!
    ... Tyrone will grab it and drag it and Miss Pua just can't resist ... >> Persia bats the string around and even though some evil person front ... > string - even thick ones like shoe/boot laces! ... > Smokey tried to haul her prey off to be killed - her prey was duly taken ...
    (rec.pets.cats.anecdotes)
  • Re: Hex to Binary Conversion
    ... In 3 byte chunks i need to grab the ... a decimal number which will be a multiplier for a function that I will have ... You want to convert an integer to a string formatted as ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Hex to Binary Conversion
    ... In 3 byte chunks i need to grab the ... to binary string conversion), then I will have to take the 2s complement of ... a decimal number which will be a multiplier for a function that I will have ... You want to convert an integer to a string formatted as ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regular expressions for replacements in Excel?
    ... willing to help and can clarify how to make the MultiLine thing work, ... By using a "Dim theTextas String" statement the system seemed to accept ... Dim lastI As Long ...
    (microsoft.public.word.vba.general)