Sharing the goodness…
Beth Massi is a Senior Program Manager on the Visual Studio team at Microsoft and a community champion for business application developers. Learn more about Beth.
More videos »
The VB Team just released an updated version of the Visual Basic Power Packs on the VB Developer Center that includes a new set of controls for Visual Studio 2005 that allow you to draw lines, rectangle and oval shapes on your Windows Forms. These controls encapsulate many of the graphics methods that are contained in the System.Drawing namespace. This enables you to draw lines and shapes in a single step without having to create graphics objects, pens, and brushes. Complex graphics techniques such as gradient fills can be accomplished by just setting some properties.
I don't know about you but I've been really looking forward to this release!
Enjoy!
PingBack from http://msdnrss.thecoderblogs.com/2007/08/13/line-and-shape-controls-for-visual-basic-just-released/
These shapes are great! I have already redesigned my current application. I love the rounded corners!
Thanks VB Team.
Hey does anyone know how to make a label tansparent, through the gradient fill?
Thanks!
Hi ,
I liked the powerpacks but i amnot able to use the shape controls like the other controls (in system.windows.forms ), when i am creating an instance of shape control and adding it to the picture box it is raising exception
"Value of type'Microsoft.VisualBasic.PowerPacks.RectangleShape' cannot be converted to 'System.Windows.Forms.Control'.
I want to use those controls like label,Tb,Checkbox and i want to add to the picturebox control .Is there any other way to create line,Rectangle ,oval and add to the picturebox .I reallly want these things in my application
Hi Dvsriram,
You can't add the shapes to a picturebox control, instead use a panel and set the backgroundimage and then add the shape container and shapes to that. For instance,
'-----------------------------
Sub Setup()
'setup the panel
Dim p As New System.Windows.Forms.Panel
p.BackgroundImage = My.Resources.MyPicture
p.BackgroundImageLayout = ImageLayout.Stretch
p.Dock = DockStyle.Fill
'setup shape container
Dim sContainer As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
sContainer.Dock = DockStyle.Fill
'setup shapes
Dim l As New Microsoft.VisualBasic.PowerPacks.LineShape
Dim o As New Microsoft.VisualBasic.PowerPacks.OvalShape
Dim r As New Microsoft.VisualBasic.PowerPacks.RectangleShape
'setup line
l.X1 = 100
l.X2 = 500
l.Y1 = 100
l.Y2 = 500
'setup oval
o.Size = New System.Drawing.Size(500, 500)
r.Location = New System.Drawing.Point(200, 200)
o.BorderColor = Color.Blue
'setup rectangle
r.Size = New System.Drawing.Size(400, 400)
r.Location = New System.Drawing.Point(100, 100)
r.BorderColor = Color.Red
'add shapes to shape container
sContainer.Shapes.Add(l)
sContainer.Shapes.Add(o)
sContainer.Shapes.Add(r)
'add shape container to the panel
p.Controls.Add(sContainer)
'add the panel to the form
Me.Controls.Add(p)
End Sub
Cheers,
-Beth
Thanks For giving the information ,
I am creating panels at runtime on clicking a particular panel .Now i am able to create the control s , lineShape,RectangleShape ,OvalShape on panel (At runtime )which is generated at runtime .
Now i have to do these things ::
I used for this class for Control (Type ) selection & resizing from
www.codeproject.com/KB/miscctrl/CSPickBoxSample1.aspx?df=100&forumid=23756&exp=0&select=1033576
while creating a control as PickBox.WireControl(ControlName) .It taking care of Control(Type)(TextBox,etc ) selection& resizing .
Now ,I need for moving and resizing controls (labels/textboxes/checkboxes/etc) and
shape controls (LineShape ,RectangleShape, OvalShape which are from
powerpacks.dll ) which i place on the Panel which are generated at runtime .
Is there any Class for creating Control Selection and Resizing Handles which accepts any typeof controls which are present on the panel at runtime ??????
I want to show the selection if user presses the control and able to resize
those controls with resizing handles for Any Typeof control . ????? Line i want only 2 SizingHandles at end points like that .
' If i release the mouse button after resizing it has to update the size or
location of that control same like in vs2005 design time environment but
here at runtime .
plzzz ,
I want a user to select & rezise a control at runtime using some grab handles on panel (also generated at runtime ) . Here i am having different controls that's the problem if i have normal control no problem .but here 4 Different controls RectangleShape,OvalShape,LineShape,Control (TextBox,....)
THis is main meaning .Please do this favour for giving a nice thing .
THanks & Regards
Sriram
Dear Beth Massi
The Power Pack elements like line or rectangle has constructor of Integer but I wanna single data type constructor. What do you offer for it.
Another question is:How can I make a class that create line and rectangle objects(or component)
Thanks a lot for your attention
Sabzpooshan
I am actually trying to develop a ladder diagram drawing application, your method is very helpful. Can include text in shape container? Thank you very much
Hi Massi ,
LineShape Control slipping from mouse pointer while moving at runtime
Dim fdragging As Boolean = False
Dim StartX, startY As Integer
Private Sub LineShape1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseDown
fdragging = True
StartX = e.X
startY = e.Y
Private Sub LineShape1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LineShape1.MouseMove
If fdragging Then
LineShape1.StartPoint = New Point(LineShape1.StartPoint.X + e.X - StartX, LineShape1.StartPoint.Y + e.Y - startY)
LineShape1.EndPoint = New Point(LineShape1.EndPoint.X + e.X - StartX, LineShape1.EndPoint.Y + e.Y - startY)
End If
Private Sub LineShape1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ShapeContainer1.MouseUp ' Used for Handling MouseUP event bcoz not identifying event LineShp Mouseup
fdragging = False
StartX = 0
startY = 0