I'm using .NET 2.0 Windows Forms and want to add "drawing" components such as lines, rectangles, etc.. I've done this before in MS Access, but I can't seem to find similar things in teh Visual Studio 2005 IDE. Where do I need to look to find these elements?
+2
A:
If you're using .NET 2 with Windows Forms, one option is to install the Visual Basic 2005 Power Pack (which is also usable from C#). It includes a series of line and shape controls.
Otherwise, you can use GDI+ and the System.Drawing namespace to draw manually.
Reed Copsey
2010-03-25 16:05:08
Thanks for the suggestion. I don't think I'll be installing the Power Pack at this time. That's the correct solution, but I'm very surprised that MS didn't include a set of drawing controls in their initial release.
Ben McCormack
2010-03-25 16:44:13
@Ben: They did, later - but I believe it's part of Microsoft.VisualBasic.dll which ships with .NET 3.0... In 2.0, you need the power pack. Otherwise, in 2.0, it's using GDI to draw by hand :(
Reed Copsey
2010-03-25 16:54:10
A:
Since these components are not in Visual Studio (the way they were for VB6), you have four choices.
- Draw the lines manually : http://msdn.microsoft.com/en-us/library/cyh3c8h8.aspx
- Use labels with borders and modify the height/width to make them LOOK like lines (but this is a hack and won't work for anything other than a straight horizontal or vertical)
- Use 3rd party controls. (I haven't run across any, but I'd bet they exist.)
- Create your own controls using the first option. (this article may prove helpful as well: http://www.vcskicks.com/custom_shape_form_region.php)
Personally, I like options 3 and 4.
Added
Hey, here's a good article for option 4! http://msdn.microsoft.com/en-us/library/aa289517(VS.71).aspx
David Stratton
2010-03-25 16:11:24