如果是简单的移动,先把图形绘制到大小和PictureBox的Bitmap上,然后再绘制到PictureBox就行。
不过在VB.NET中用GDI绘制最好用BufferedGraphics图形缓冲区,速度马马虎虎(VB就这样了),但是不闪烁,不存在背景擦除的问题。
用覆盖的方法,再声明一个pen,颜色为picturebox1.backcolor。 我这里就把图片背景当成白色。
Dim ag As Graphics
Dim pen1 As New Pen(Color.FromArgb(255, 255, 255, 255), 2)
ag = PictureBox1.CreateGraphics
Dim rect As New Rectangle(0, 0, 50, 50)
Dim pen As New Pen(Color.FromArgb(255, 200, 0, 200), 2)
ag.DrawRectangle(pen, rect)
ag.DrawRectangle(pen1, rect)
ag.TranslateTransform(150, 50)
ag.DrawRectangle(pen, rect)