how to draw a round rectangle[emergency]
-
as topic, i can find DrawEllipse, DrawRectangle in picturebox control but i cant find DrawRoundRec in VB.Net !! anyone can help me plz...:confused: this is the roundrectangle i mean...(of coz the lines must be connected each other) ____ (____)
That's because there isn't one. You're going to have to draw them yourself, line segment by line segment. You might want to look into GraphicsPath for creating an object that can be drawn all at once. RageInTheMachine9532
-
as topic, i can find DrawEllipse, DrawRectangle in picturebox control but i cant find DrawRoundRec in VB.Net !! anyone can help me plz...:confused: this is the roundrectangle i mean...(of coz the lines must be connected each other) ____ (____)
Hi, Here's a couple of functions I wrote that will draw you a rectangle with rounded corners. I just ripped them out of my own code, so I hope I didn't miss anything. Just call DrawRoundedRectangle and pass it your graphics object, a rectangle to draw in and an integer specifying how "round" you want the corners to be. If you have a program drop me a line. ' Draw an empty rectangle with rounded corners using the same pen for all sides Public Sub DrawRoundedRectangle(ByRef prGraphics As Graphics, ByRef prPen As Pen, ByRef prRect As Rectangle, ByVal pvRounding As Integer) Dim lrectSurface As GraphicsPath lrectSurface = BuildRoundedRectangle(CreateRectangle(prRect.Left, prRect.Top, prRect.Width - 1, prRect.Height - 1), pvRounding) prGraphics.DrawPath(prPen, lrectSurface) End Sub ' Build a graphic path for a rounded rectangle/square Public Function BuildRoundedRectangle(ByRef prRect As Rectangle, ByVal pvRounding As Integer) As GraphicsPath Dim lPath As New GraphicsPath() Dim lHalf As Integer = CInt(pvRounding / 2) With prRect lPath.StartFigure() lPath.AddArc(.Left, .Top, pvRounding, pvRounding, 180, 90) lPath.AddLine(.Left + lHalf, .Top, .Right - lHalf, .Top) lPath.AddArc(.Right - pvRounding, .Top, pvRounding, pvRounding, 270, 90) lPath.AddLine(.Right, .Top + lHalf, .Right, .Bottom - pvRounding) lPath.AddArc(.Right - pvRounding, .Bottom - pvRounding, pvRounding, pvRounding, 0, 90) lPath.AddLine(.Right - lHalf, .Bottom, .Left + lHalf, .Bottom) lPath.AddArc(.Left, .Bottom - pvRounding, pvRounding, pvRounding, 90, 90) lPath.AddLine(.Left, .Bottom - lHalf, .Left, .Top + lHalf) lPath.CloseFigure() End With BuildRoundedRectangle = lPath End Function Nursey
-
Hi, Here's a couple of functions I wrote that will draw you a rectangle with rounded corners. I just ripped them out of my own code, so I hope I didn't miss anything. Just call DrawRoundedRectangle and pass it your graphics object, a rectangle to draw in and an integer specifying how "round" you want the corners to be. If you have a program drop me a line. ' Draw an empty rectangle with rounded corners using the same pen for all sides Public Sub DrawRoundedRectangle(ByRef prGraphics As Graphics, ByRef prPen As Pen, ByRef prRect As Rectangle, ByVal pvRounding As Integer) Dim lrectSurface As GraphicsPath lrectSurface = BuildRoundedRectangle(CreateRectangle(prRect.Left, prRect.Top, prRect.Width - 1, prRect.Height - 1), pvRounding) prGraphics.DrawPath(prPen, lrectSurface) End Sub ' Build a graphic path for a rounded rectangle/square Public Function BuildRoundedRectangle(ByRef prRect As Rectangle, ByVal pvRounding As Integer) As GraphicsPath Dim lPath As New GraphicsPath() Dim lHalf As Integer = CInt(pvRounding / 2) With prRect lPath.StartFigure() lPath.AddArc(.Left, .Top, pvRounding, pvRounding, 180, 90) lPath.AddLine(.Left + lHalf, .Top, .Right - lHalf, .Top) lPath.AddArc(.Right - pvRounding, .Top, pvRounding, pvRounding, 270, 90) lPath.AddLine(.Right, .Top + lHalf, .Right, .Bottom - pvRounding) lPath.AddArc(.Right - pvRounding, .Bottom - pvRounding, pvRounding, pvRounding, 0, 90) lPath.AddLine(.Right - lHalf, .Bottom, .Left + lHalf, .Bottom) lPath.AddArc(.Left, .Bottom - pvRounding, pvRounding, pvRounding, 90, 90) lPath.AddLine(.Left, .Bottom - lHalf, .Left, .Top + lHalf) lPath.CloseFigure() End With BuildRoundedRectangle = lPath End Function Nursey
thanks for replying me!! i think i need ur program understand how the coding works, can u send to me? my email is mjlai83@pd.jaring.my thanks again for help!!