Click here to Skip to main content
15,892,289 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How To draw arrow or line while design windows form i want to draw a line or arrow like draw textbox or group box, like any component in Toolbox.

Is there any component for arrows and lines?
Posted

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#.
 
Share this answer
 
This is easy enough. You need to handle the even System.Window.Forms.Control.Paint or override the virtual method System.Window.Forms.Control.OnPaint of some control (including Form). You will get an instance of System.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 call System.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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900