Text Lines/MeasureString

  • Thread starter Thread starter Martin Madreza
  • Start date Start date
M

Martin Madreza

Hello,

i'm searchin for an easy solution

i'v got for e.g. an text that go after measurestring 4 lines

This
is
my
Text

No i want to read the text of the lines like lines[0] or what ever -
there is noc line break.

an textbox or richtextbox ios easier no solution. hope someone could
help

MM
 
Split it to strings array.

string[] str = textBox1.Text.Split('\n');

Or you can use lines array of textbox control:

str[0] from the previous example is equal to textBox1.Lines[0];

Gaidar
 
hi

thats exactly my problem, there is no "\n" or Environment.NewLine


the text is one line - This is my text, after MesureString or putin it
into a text box with a special width i've got

This
is
my
text

without any linebreak (\n) (the hole text is in textbox.lines[0]) - but
the system calculated the text into 4 lines. i do not want to build my
own algorithm

hope we come now closer to my problem

mm
 
Hi Martin,

The text is probably wrapped, and to find out which word or what text is
at what line after the text is wrapped I fear you will have to write your
own algorithm.
 
i wonder why, it's already have to be done by the measure string or
wrap algorithm of a textbox...

thanks anyway
 
It doesn't have to wrap. You may specify NoWrap in a
StringFormat.FormatFlags when using MeasureString, or set TextBox.WordWrap
to false (TextBox.Wrap for web).
 
Back
Top