using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form {
protected override void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
g.FillRectangle(Brushes.White, this.ClientRectangle);
FontFamily ff = new FontFamily("Times New Roman");
Font f = new Font(ff, 12);
String s = "Height: " + f.Height;
SizeF sf = g.MeasureString(s, f, Int32.MaxValue,StringFormat.GenericTypographic);
RectangleF r = new RectangleF(0, 0, sf.Width, f.Height);
g.DrawRectangle(Pens.Black, r.Left, r.Top, r.Width, r.Height);
g.DrawString(s, f, Brushes.Black, r, StringFormat.GenericTypographic);
f.Dispose();
}
public static void Main() {
Application.Run(new Form1());
}
}
|