Wordwrap in a label[SOLVED]

Started by Construed, Sat 18/02/2012 02:11:41

Previous topic - Next topic

Construed

Is it possible to use word wrap in a label?
Also
Is there any workaround for adding scrollbar to a label?
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

RickJ

You are probably wanting to use a listbox.  You will have to do word wrap and justification yourself.  There are functions that return the pixel length of a string using a specified font. 

Construed

#2
Ah, okay, I've got a label that's kinda heavily tied in to different variables etc, but I'm assuming that's a no go with that so i suppose i need to focus on switching over to ListBox. Thanks for the reply bud :D
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Khris

It's not only possible, labels word wrap by default. But no, you can't easily scroll a label.

Construed

Ah, ok cause i have a label that is used as an input box but the text stops at the end,
I had to extend it eastward to fit more letters but it may be because of some predefined word formatting code previously implemented.
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Khris

Input boxes don't wrap, labels wrap. InputBox != Label.

Construed

#6
Yea, this is a very shiesty use of a label:
Code: ags

#define LINE_WIDTH 99 // Max number of characters on a line
#define LINE_COUNT 5 // Max number of lines in the textbox

Code: ags

void PushLine(String line)
{
  if (line.Length > LINE_WIDTH)
  {
    PushLine(line.Truncate(LINE_WIDTH));
    PushLine(line.Substring(LINE_WIDTH, line.Length - LINE_WIDTH));
    return;
  }
  
  String text;

  text = String.Format("%s[%s", lblOutput.Text, line); ////////This is the label


  int i = text.Length;
  int count = 0;
  int pos = -1;
  while (i)
  {
    if (text.Chars[i] == '[')
      count++;
    
    if (count == LINE_COUNT)
    {
      pos = i;
      i = 0;
    }
    else
      i--;
  }
  
  lblOutput.Text = text.Substring(pos + 1, text.Length - pos - 1);
}
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

Construed

Well, I'm guessing there is no possibility of enhancing this label beyond what it already is.
So I'm going to say [SOLVED]

Answer: use ListBox
I felt sorry for myself because I had no shoes.
Then I met the man with no feet.

SMF spam blocked by CleanTalk