public partial class Stringformat : Form
...{
public Stringformat()
...{
InitializeComponent();
SetStyle(ControlStyles.Opaque, true);
Point p = new Point(0, 0);
Size s = new Size(500, 300);
//Bounds = new Rectangle(0, 0, 500, 300);
Bounds = new Rectangle(p, s);//窗體大小及相對於父客體的位置(0,0)
}
protected override void OnPaint(PaintEventArgs e)//重定義基類OnPaint()方法
...{
Graphics g = e.Graphics;
int y = 0;
g.FillRectangle(Brushes.White, ClIEntRectangle);//繪制窗體背景色
Rectangle rect = new Rectangle(0, y, 400, Font.Height);
//g.FillRectangle(Brushes.Blue, rect);//墳兗一個矩形
public partial class Stringformat : Form
...{
public Stringformat()
...{
InitializeComponent();
SetStyle(ControlStyles.Opaque, true);
Point p = new Point(0, 0);
Size s = new Size(500, 300);
//Bounds = new Rectangle(0, 0, 500, 300);
Bounds = new Rectangle(p, s);//窗體大小及相對於父客體的位置(0,0)
}
protected override void OnPaint(PaintEventArgs e)//重定義基類OnPaint()方法
...{
Graphics g = e.Graphics;
int y = 0;
g.FillRectangle(Brushes.White, ClIEntRectangle);//繪制窗體背景色
Rectangle rect = new Rectangle(0, y, 400, Font.Height);
//g.FillRectangle(Brushes.Blue, rect);//墳兗一個矩形
public partial class Stringformat : Form
...{
public Stringformat()
...{
InitializeComponent();
SetStyle(ControlStyles.Opaque, true);
Point p = new Point(0, 0);
Size s = new Size(500, 300);
//Bounds = new Rectangle(0, 0, 500, 300);
Bounds = new Rectangle(p, s);//窗體大小及相對於父客體的位置(0,0)
}
protected override void OnPaint(PaintEventArgs e)//重定義基類OnPaint()方法
...{
Graphics g = e.Graphics;
int y = 0;
g.FillRectangle(Brushes.White, ClIEntRectangle);//繪制窗體背景色
Rectangle rect = new Rectangle(0, y, 400, Font.Height);
//g.FillRectangle(Brushes.Blue, rect);//墳兗一個矩形
text is much longer, and drawn ";
longString += "into a rectangle that is higher than ";
longString += "one line,so that it will wrap. It is ";
longString += "very easy to wrap text using GDI+.";
g.DrawString(longString, afont, Brushes.Black, rect);
afont.Dispose();
}
}
運行效果圖: