Solved

Display a Powerpack RectangleShape at runtime

Posted on 2009-05-08
2
939 Views
Last Modified: 2012-05-06
The generation of the shape is controlled at runtime by data read from a file to set all the properties I care about e.g. Size, Location, Color, BorderWidth etc. Now, I would like to render it on a form. This should be trivial, but I can't just add it as a control so something different must be done...

Do I need to create some container on the form first, am I missing one of the commands to cause it to draw and/or connect it to a specific form, something else?? Probably a dumb question...
Dim rc As RectangleShape
        rc = New RectangleShape
        rc.Location = New Point(100, 100)
        rc.Size = New Point(150, 150)
        ' ... now what

Open in new window

0
Comment
Question by:MarkBottomley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
ToddBeaulieu earned 125 total points
ID: 24338912
Check this out:

http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.rectangleshape.aspx

I whipped this example up...
    Private Sub DrawRectangle()
        Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
        Dim rect1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape
 
        ' Set the form as the parent of the ShapeContainer.
        canvas.Parent = Me
 
        With rect1
            ' Set the ShapeContainer as the parent of the RectangleShape.
            .Parent = canvas
            .BorderWidth = 2
            .BorderStyle = DashStyle.Solid
            .BorderColor = Color.DarkBlue
 
            .CornerRadius = 5
            .FillColor = Color.LightBlue
            .FillStyle = FillStyle.Solid
            .FillGradientStyle = FillGradientStyle.ForwardDiagonal
            .FillGradientColor = Color.AntiqueWhite
 
            ' Set the location and size of the rectangle.
            .Left = 10
            .Top = 10
            .Width = 100
            .Height = 100
        End With
 
    End Sub

Open in new window

0
 

Author Closing Comment

by:MarkBottomley
ID: 31579566
The addition of a Canvas is not obvious when just adding the PowerPack items in the form designer - thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question