DrawString() - ignoring format?

hi

heres the code

*****************************
this->format = new StringFormat();
this->format->Alignment = StringAlignment::Near;// this line works
this->format->Trimming = StringTrimming::EllipsisWord;// this line doesnt
this->gr->DrawString(text, this->font, this->colour, this->area, this->format);
*****************************

the text doesnt fit within the area specified. but its not being trimmed, even though ive specified stringtrimming::ellipsisword.

it is accepting the format - if i change alignment to centre or far it works fine, but no matter what i set the trimming to, it just cuts the bottom line of my text in half - very amateur looking!

ive done it exactly how its shown in msdn - so what am i missing



Answer this question

DrawString() - ignoring format?

  • MMatt

    I guess you should also set the LineAlignment property of the StringFormat, and make sure you're not painting in an area that can contain more than 1 line of text for your selected font.
  • Dave Marsh

    Try setting

    this->format->FormatFlags = StringFormatFlags::LineLimit;

    Tony

  • DrawString() - ignoring format?