110,535
社区成员
发帖
与我相关
我的任务
分享
void panel1_Paint(object sender, PaintEventArgs e)
{
Panel _Panel = (Panel)sender;
Graphics _Graphcis = Graphics.FromHwnd(_Panel.Handle);
_Graphcis.DrawLine(new Pen(Brushes.Red, 1), new Point(0, 0), new Point(_Panel.Width, _Panel.Height));
_Graphcis.Dispose();
}
protected override void OnPaint(PaintEventArgs e)
{
//base.OnPaint(e);
Graphics g = e.Graphics;
using (Pen blackPen = new Pen(Color.Black,2))
{
if (ClientRectangle.Height / 10 > 0)
{
for (int y = 0; y < ClientRectangle.Height; y += ClientRectangle.Height / 10)
{
g.DrawLine(blackPen,new Point(0,0),new Point(ClientRectangle.Width,y));
}
}
}
}