开发者

How do I add "drawing" components to a WinForms control?

I'm using .NET 2.0 Windows Forms and want to add "drawing" components such as lines, rectangles, etc.. I've done thi开发者_如何学编程s 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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜