3 Pluspunkte 0 Minuspunkte

Wie kann ich machen das der Text in einem Rectangle sich automatisch umbricht wenn er die Breite des Rectangle überschreitet?

e.Graphics.DrawString(Name, Control.DefaultFont, Brushes.Black, BoundingBox().Location);
von  

2 Antworten

2 Pluspunkte 0 Minuspunkte

Wenn BoundingBox() ein Rectangle ist dann ist die Location Eigenschaft ein Point. Du musst das Rectangle übergeben.

e.Graphics.DrawString(Name, Control.DefaultFont, Brushes.Black, BoundingBox());

von (706 Punkte)  
0 Pluspunkte 0 Minuspunkte

Das kannst du mit einem StringFormatFlag.FitBlackBox.

StringFormat stringFormat = new StringFormat();
stringFormat.FormatFlags = StringFormatFlags.FitBlackBox;

e.Graphics.DrawString(Name, Manager.Instance.Font, Brushes.Black, BoundingBox().Location, stringFormat);
von (532 Punkte)  
Der Text hängt trotzdem über.