I simply did this. XFont printfont ... string Value = some long string.... Rectangle r = some text rectangle XStringFormat f = XStringFormat ...
XSize lengthOfText = gfx.MeasureString(Value, printfont); string textValue = Value; if (lengthOfText.Width > (double)r.Width) { while (lengthOfText.Width > (double)r.Width) { textValue = textValue.Remove(textValue.Length - 1, 1); lengthOfText = gfx.MeasureString(textValue, printfont); } } gfx.DrawString(textValue, printfont, XBrushes.Black, r, f);
Works like a charm.
|