// Function: draw a line created by PEN.
// (in this case using create Pen. The advantage is that, when an object (pen) goes out of scope, using the structure will automatically call Dispose (), will be deleted PEN.
// If the object creation by other means (usually very fee resources), be sure to explicitly call Dispose (), such as:
// "Graphics G = this.CreateGraphics ();
// ........
// ........
// g.Dispose (); "
// IMPORTANT:
// create Pen, Pen color and thickness to obtain height of the client area and the Width
a using System;
a using System.Collections.Generic;
a using System.ComponentModel;
a using the System.Data;
a using System .Drawing;
the using the System.Text;
the using the System.Windows.Forms;
namespace myDrawPanA
{
public partial class the Form1: Form1
{
public the Form1 ()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
//base.OnPaint(e);
Graphics g = e.Graphics;
using (Pen myPen = new Pen(Color.Red,1))
{
if (ClientRectangle.Height/10>0)
{
for (int y=0; y< ClientRectangle.Height; y += ClientRectangle.Height/10)
{
g.DrawLine(myPen,new Point(0,0), new Point(ClientRectangle.Width,y));
}
}
}
}
}
}