如何将线画到容器上(PictureBox)上
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace C
{
/// <summary>
/// 棋盘类
/// </summary>
class ChessBoard
{
public int line = 10;
public int linespace = 30;
public int margin = 30 / 2;
public PictureBox picctrl;
/// <summary>
/// 画棋盘
/// </summary>
public void ShowChessBoard()
{
Pen Mypen = new Pen(Color.Green, 1);
SolidBrush brush = new SolidBrush(Color.Gold);
Bitmap bmp = new Bitmap(picctrl.Width,picctrl.Height);
Graphics gr = Graphics.FromImage(bmp);
//画横线
for (int i = 0; i < line; i++)
{
gr.DrawLine(Mypen, margin, margin + linespace * i,
(line - 1) * linespace + margin, margin + linespace * i);
}
//画竖线
for (int i = 0; i < line; i++)
{
gr.DrawLine(Mypen,linespace * i + margin, margin,
margin + linespace * i, (line - 1) * linespace + margin);
}
picctrl.BackgroundImage = bmp;
}
}
}
线已经画好(19*19的方格),现在想把这些线放到容器中(PictureBox)中,不知道怎么放了,麻烦各位兄弟帮帮忙!!!小弟感激不尽...