在PictureBox中画一个圆 [英] Draw a Circle in a PictureBox
本文介绍了在PictureBox中画一个圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图片框,40 x 40,黑色.我想画一个40 x 40的圆圈,颜色-白色,圆圈中间的文字,前色-黑色.
我该怎么做?
I have a picturebox, 40 x 40, backcolor black. I want to draw a circle 40 x 40, color - white and text in the center of the circle, forecolor - black.
How do I do this???
推荐答案
这是完全有可能的(您需要获取图片的Graphics
实例并在其上绘制),但是没有道理.相反,您可以更轻松地使用自定义的Control
,包括Form
或Panel
.类PictureBox
不会为其添加任何有用的功能,只会造成一些麻烦并占用额外的运行时和内存.
问题是:该怎么办?我在过去的解决方案中对此进行了解释:我清除了旧图纸中的面板 [
This is quite possible (you need to get an instance of theGraphics
of the picture and draw on it), but makes no sense. Instead, you can more easily draw on a customControl
, includingForm
orPanel
. The classPictureBox
won''t add any useful functionality to it, will only create some hassles and eat up extra runtime and memory.
The question is: what to do instead? I explain it in my past solution: How do I clear a panel from old drawing[^].
The link provided by Mika also shows how to do it right.
—SA
图片框的想法是可以将图片加载到其中.它并不意味着直接绘制.
这是一篇好看的文章: http://www.bobpowell.net/picturebox.htm [ ^ ]
The idea of the picturebox is that you can load a picture into it. It''s not meant to be drawn at directly.
Here''s one good looking article: http://www.bobpowell.net/picturebox.htm[^]
这篇关于在PictureBox中画一个圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文