using System; using System.Drawing; using System.Windows.Forms; class MainForm : Form { [STAThread] static void Main () { Application.Run (new MainForm ()); } protected override void OnPaint (PaintEventArgs pevent) { base.OnPaint (pevent); Graphics g = pevent.Graphics; String s = "The quick brown fox jumped over the lazy dogs."; // Regular Rectangle r1 = new Rectangle (0, 0, 100, 22); g.DrawRectangle (Pens.Red, r1); g.DrawString (s, Font, Brushes.Black, r1); g.DrawString ("Regular", Font, Brushes.Black, 110, 5); // Line Limit Rectangle r2 = new Rectangle (0, 40, 100, 22); StringFormat sf = new StringFormat (); sf.FormatFlags = StringFormatFlags.LineLimit; g.DrawRectangle (Pens.Red, r2); g.DrawString (s, Font, Brushes.Black, r2, sf); g.DrawString ("Line Limit - 2 Lines", Font, Brushes.Black, 110, 45); // Line Limit - Not enough room for any lines Rectangle r3 = new Rectangle (0, 80, 100, 8); g.DrawRectangle (Pens.Red, r3); g.DrawString (s, Font, Brushes.Black, r3, sf); g.DrawString ("Line Limit - 1 Line", Font, Brushes.Black, 110, 85); } }