如何绘制没有"CreateGraphics"的控件?方法? [英] How to draw on a control which hasn't "CreateGraphics" method?
本文介绍了如何绘制没有"CreateGraphics"的控件?方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个函数,该函数包含在没有"CreateGraphics"方法的控件上绘制的代码(此控件位于Form上).如何创建此功能?
I want to create a function, this function contains code to draw on a control which has not "CreateGraphics" method (this control is on Form). How to create this function? Thanks.
推荐答案
可以将Graphics
实例或该Control
实例作为参数传递给函数:
Can passGraphics
instance or thatControl
instance as parameter to the function:
private void DrawFunction(Control control)
{
// Create a Graphics object for the Control.
Graphics g = control.CreateGraphics();
// Draw shapes etc...
}
private void DrawFunction(Graphics graphics)
{
//Draw shapes etc...
}
这篇关于如何绘制没有"CreateGraphics"的控件?方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文