windowsForm中的LIne和Arrows [英] LIne and Arrows in windowsForm
本文介绍了windowsForm中的LIne和Arrows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在设计窗口形式时绘制箭头或线条我想画一条线或箭头 像绘制文本框或组合框, 像任何工具箱中的组件 。
箭头和线条是否有任何组件?
推荐答案
除非您使用的是Visual Studio 2012和.NET 4.5,否则Visual Studio中没有任何组件可以执行此操作。但是, Visual Basic Power Pack 3.0 [ ^ ]确实将这些控件添加到工具箱中。
是的,它们可用于C#。
There is no component that comes with Visual Studio to do that, unless you're using Visual Studio 2012 and .NET 4.5. There is, however, the Visual Basic Power Pack 3.0[^] which does add those controls to the ToolBox.
Yes, they can be used in C#.
这很容易。你需要处理偶数System.Window.Forms.Control.Paint
或覆盖虚方法System.Window.Forms.Control.OnPaint
的某些控件(包括Form
)。您将获得一个System.Drawing.Graphics
的实例,通过事件参数参数传递给您的处理程序方法。用它来绘制控件。要修改图像,请更改用于绘图的数据并调用System.Window.Forms.Control.Invalidate
。为了防止闪烁,请使用双缓冲。
请参阅我过去的答案以获取更多详细信息:
< a href =http://www.codeproject.com/Answers/201863/capture-the-drawing-on-a-panel#answer1>捕获面板上的图纸 [ ^ ],
什么样的俏皮方法是Paint? (DataGridViewImageCell.Paint(...)) [ ^ ],
如何加速我的vb.net应用程序? [ ^ ],
mdi子表单之间的绘制线 [ ^ ],
用C#.net鼠标滚轮缩放图像 [ ^ ]。
我希望你有这个主意。
-SA
This is easy enough. You need to handle the evenSystem.Window.Forms.Control.Paint
or override the virtual methodSystem.Window.Forms.Control.OnPaint
of some control (includingForm
). You will get an instance ofSystem.Drawing.Graphics
, passed to your handler method through event arguments parameter. Use it to draw on the control. To modify the image, change the data used for drawing and callSystem.Window.Forms.Control.Invalidate
. To prevent flicker, use double buffering.
Please see my past answers for further detail:
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
How to speed up my vb.net application?[^],
Drawing Lines between mdi child forms[^],
Zoom image in C# .net mouse wheel[^].
I hope you got the idea.
—SA
这篇关于windowsForm中的LIne和Arrows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文