VS2019 调用图形控件Picturebox 控件缓冲内容方法
如题:目的:VS2019 在非Picturebox 控件的方法中调用Picturebox 控件的命令
调用过程
1、定义私有变量
private BufferedGraphics bufferedGraphics;
2 、捕捉范围
BufferedGraphicsContext context = BufferedGraphicsManager.Current;
bufferedGraphics = context.Allocate(this.pnlCanvas.CreateGraphics(), this.pnlCanvas.ClientRectangle);
3、在自定义方法中使用
Graphics g = bufferedGraphics.Graphics;
g.FillEllipse(new SolidBrush(Color.Chocolate), (int)(posX - 6), (int)(posY - 6), 12, 12);
以上就可以在程序中自由使用了,