日期:2014-05-18 浏览次数:21090 次
int rows = 10, cols = 10, w = 0,h=0;
private void panel1_Paint_2(object sender, PaintEventArgs e)
{
w = panel1.Width / cols;
h = panel1.Height / rows;
w = Math.Min(w, h);
for (int i = 0; i < cols;i++ )
{
for (int j = 0; j < rows; j++)
{
e.Graphics.DrawRectangle(Pens.Red, new Rectangle(w*i,w*j,w,w));
}