110,534
社区成员
发帖
与我相关
我的任务
分享
public Form1()
{
InitializeComponent();
Pen p = new Pen(Color.Yellow);
Graphics gThin = pictureBox1.CreateGraphics();
gThin.DrawLine(p, 50, 50, 100, 100);
//PersonThinBuilder ptb = new PersonThinBuilder(gThin, p);
//ptb.Build();
}
private PictureBox pictureBox1 = new PictureBox();
private void Form1_Load(object sender, System.EventArgs e)
{
pictureBox1.Dock = DockStyle.Fill;
pictureBox1.BackColor = Color.White;
pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
this.Controls.Add(pictureBox1);
}
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawString("This is a diagonal line drawn on the control",
new Font("Arial",10), System.Drawing.Brushes.Blue, new Point(30,30));
g.DrawLine(System.Drawing.Pens.Red, pictureBox1.Left, pictureBox1.Top,
pictureBox1.Right, pictureBox1.Bottom);
}