using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //Graphicsオブジェクトの作成 Graphics g = pictureBox1.CreateGraphics(); //Penオブジェクトの作成(幅3黒色) Pen p = new Pen(Color.Black, 3); //(0,0)-(100,100)に線を引く g.DrawLine(p, 0, 0, 100, 100); //リソースを開放する p.Dispose(); g.Dispose(); } } }