C#中的Graphics g = e.Graphics是什么意思?

protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
using (Pen bluePen = new Pen(Color.Red, 1))
{
if (ClientRectangle.Height / 10 > 0)
{
for (int y = 0; y < ClientRectangle.Height; y += ClientRectangle.Height / 10)
{
g.DrawLine(bluePen, new Point(0, 0), new Point(ClientRectangle.Width, y));
}
}
}

}
求大神指教Graphics g = e.Graphics; 这句话是什么意思呢?

你就把Graphics看成是画布,e.Graphics就是此控件的画布。事件参数e的内容是随着事件种类变化的。
温馨提示:内容为网友见解,仅供参考
第1个回答  2014-10-10
实例化图形设备
相似回答