|
为什么画出来的不是18行 11列
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int hang = 18;//定义行
int lie = 11;//定义列
private void btnStart_Click(object sender, EventArgs e)
{
int fgwid = this.gamepanel.Width / lie;//获得方格的宽度
int fghei = this.gamepanel.Height / hang;//获得方格的高度
for (int row = 0; row < hang; row++)//控制行数
{
for (int clu = 0; clu < lie; clu++)//控制列数
{
Graphics g=Graphics.FromHwnd(this.gamepanel.Handle);
g.DrawRectangle(Pens.Black, new Rectangle(row * fgwid, clu * fghei, fgwid, fghei));
}
}
}
}
|
|