MyPointsList.Add(New Point(ctrl.Width, ctrl.Height \ 2)) MyPointsList.Add(New Point(ctrl.Width \ 2, 0)) MyPointsList.Add(New Point(0, ctrl.Height \ 2)) Optional ByVal NumberOfSides As Integer = 3, Optional ByVal OffsetAngleInDegrees As Double = 0) Public Sub Shape(ByVal ctrl As Control, _ If the control size is square such as 300 X 300 then the control ends up as a circle shape.
HOW TO BUILD OCTAGON WINDOWS CODE
Have added to the original code so you can now have controls in the shape of a pointed oval.įor now this can only be horizontal or vertical. Like this where the first two shapes are PictureBoxes and the hexagon isĪround September 7th, 2009 we tweaked the code to allow for two-sided shapes.>
The above example creates two shaped PictureBoxes and a stretched hexagon shaped button!! If the containing area is square you end up with a circle, otherwise you will get a pointed oval. If NumberOfSides With a version of the code below this post the minimum is now 2 sides. Optional ByVal OffsetAngleInDegrees As Double = 0) Optional ByVal NumberOfSides As Integer = 3, _ Public Sub Shape( ByVal ctrl As Control, _ Public Const DegreesToRadians As Double = 180 / Pi Or vice-versa than the regular shape is stretched to fit this shape.įrom the PROJECT menu using VB.Net 2008 or a later version select If the dotted rectangle ( that the control is drawn out within ) is wider than it is tall So if you have a square control like a square button or picturebox, you will get a regular shape. Into the shape you want within the bounds of the original shape of the control. Well using just one line of code you can transform any of your controls This led to creating the following code which acts on the base class CONTROLfor ALL controls!! Saw a post earlier which reminded me about Extension Methods.
This will allow you all to suggest any changes, however small. This document was originally published as an MSDN discussion here on September 3rd, 2009