我在form2中的button_click事件中写的
private void button1_Click(object sender, EventArgs e) { //上面是一段对数据库的其他操作 form1.drawBanpi1(); }
form1中的函数是这样的
private void drawSquare(Graphics graphic, Pen pen, int x, int y, int Wide, int hight) { graphic.DrawRectangle(pen, x, y, Wide, hight); } public void drawBanpi1() { for (int i = 115; i <= 115 + 20 * (dataGridView2.Rows.Count - 2); i += 20) { square = setSquare(65, i, 200, 10); drawSquare(this.CreateGraphics(), Pens.Black, square.Square_X, square.Square_Y, square.Square_Wide, square.Square_Hight); } }
可是form1的picturebox上并未画出矩形,为什么?还有我想在画的矩形上填充颜色并且显示出矩形的编号,怎么编程?在线等~~~
winform画图要一直画呢。