1

I'm developing an app in Visual Studio (C#, Windows Forms, .NET 4.7.1). Back in the old days of Visual Basic 6, there were buttons on the toolbar that provided the ability to draw arbitrary lines and rectangles/circles on the form. See screenshot of the old VB6 control toolbar below.

These seem to be gone in VB.net and the current Visual Studio dev environments. Yes I realize that the Visual Studio environment is NOT the same as the old Visual Basic dev environment. However, it just seems the ability to draw lines and shapes is a primitive/basic feature that would be afforded to any GUI used for developing Windows forms.

Is there any way to add this ability, so that arbitrary angle/length lines and basic shapes like rectangles and ellipses can be drawn on Windows forms without the need to do this programmatically?

enter image description here

Ryan Griggs
  • 2,457
  • 2
  • 35
  • 58
  • It's something you can do yourself in 10 minutes, then extend as you please, if / when needed. Much more flexible – Jimi Mar 08 '23 at 18:00
  • There are plenty different ways to do this. There are toolsets available in places like the VS Marketplace that you can use. use things like panels and set the appropriate display properties or even draw on the form canvas using various graphic and paint events – Hursey Mar 08 '23 at 20:03
  • 1
    @jimi not an answer... – Ryan Griggs Mar 09 '23 at 00:17
  • 1
    @Hursey I specifically asked for solutions that don't require drawing programmatically, and also want lines with arbitrary angles. – Ryan Griggs Mar 09 '23 at 00:18
  • Yep, that appears to be a comment. I mean, you can create a Custom Control, derived from the `Control` class, override `OnPaint()`, draw the content of the shape (and its border, if needed). Setup a couple of properties for the colors -- A line can be draw the same way. Use a property to get the rotation angle, use `Matrix.RotateAt()` to set the rotation (at the center of the ClientRectangle), pass the Matrix to `GraphicsPath.Transform()`, get the GraphicsPath's bounds to redefined the shape's bounds, draw the path – Jimi Mar 09 '23 at 00:24
  • 2
    yes, we waiting for these people to post their examples if it is oh so easy. We are talking about a design time goal here - not a end user runtime goal. yes, folks, do share, will you!!! – Albert D. Kallal Mar 10 '23 at 06:15
  • @RyanGriggs Do you have time to check Albert's answer. If it solves your issue, you could click '✔' to mark it as an answer to change its status to Answered. It will also help others to solve a similar issue. – Jiale Xue - MSFT Mar 16 '23 at 08:19

1 Answers1

4

For quite a long time, there was a vs add-in (visual basic) that allowed this.

And the so called VB power pack still does and can work in vs2022.

I NOTE vs2022, since it is the VERY FIRST version of visual studio that is x64 bits (yes, ALL THESE years, vs was still x32 bits, all the way up to vs2019).

Doing some R&D, the suggestions are that the power packs 10, 11, 12 don't work in vs2022.

I not had the the the time to test above ideas.

However, quite a few suggested that the visual basic power pack 3.0 works with vs2022, and works as x32 or x64 bits.

Edit: better choice seems to use power pack 9.0

So, giving this a try?

Yes, it does work.

I get/see this now:

enter image description here

So, first is to download and install power pack v 3.0.

(edit: again, 9.0 seems to be the better choice).

However, 9.0 also seems to work according to this post:

How do I view and edit Visual Basic Power Pack shapes in a Windows Form app with Visual Studio 2022?

Once you download 9.0.

Then you have to install, and then you should be able to create a new toolbox item, choose add items, and you see/find this:

enter image description here

Looking at above, it looks to be 9.0. So that is the version you want to download + install (the nuget package does NOT work).

So, all we have to do is find a link to 9.0.

And you want to exit vs before you install.

As noted, it looks that I am using 9.0, and as noted by others and in the above link, 10,11,12 don't work, but 9.0 does.

I'm using vs2022, .net 4.8.

Now, all we have to do is find a "decent" 9.0 link for the download.

Edit: This link seems to be ok

So, this link seems to work - it called power pack 3.0, but the version shows 9.0 after installing.

https://www.malavida.com/en/soft/visual-basic-power-packs/

Albert D. Kallal
  • 42,205
  • 3
  • 34
  • 51