代碼如下:
public partial class Draw : Form
...{
public Draw()
...{
InitializeComponent();
SetStyle(ControlStyles.Opaque, true);
}
protected override void OnPaint(PaintEventArgs e)
...{
Graphics g = e.Graphics;
g.FillRectangle(Brushes.Wheat, ClientRectangle);
using (Pen pen = new Pen(Color.Red, 1))
...{
for (int y = 0; y<=ClientRectangle.Height; y += ClientRectangle.Height / 12)
...{
g.DrawLine(pen, new Point(0, 0), new Point(ClientRectangle.Width, y));
}
}
g.FillEllipse(Brushes.Red,new Rectangle(100,100,50,50));
}
}運行得效果:

4659

被折叠的 条评论
为什么被折叠?



