Thanks to your example .paul. , I found that I didn't draw the arcrect path.
I've changed my code in that way and now I have a good looking roundedrectangle.
Here's my code:
Thanks for the hints,Code:Imports System.Drawing Imports System.Drawing.Drawing2D Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click Application.Exit() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim g As Graphics = e.Graphics Dim width As Integer = Me.ClientRectangle.Width Dim heigth As Integer = Me.ClientRectangle.Height Dim rect As Rectangle = New Rectangle(10, 20, width - 50, heigth - 50) Dim path As GraphicsPath = GetRoundedRectPath(rect, (width / 10)) g.FillPath(Brushes.Yellow, Path) g.DrawPath(Pens.Black, path) path.Dispose() End Sub Function GetRoundedRectPath(ByVal rect As Rectangle, ByVal radius As Integer) As GraphicsPath Dim diameter As Integer = 2 * radius Dim arcrect As Rectangle = New Rectangle(rect.Location, New Size(diameter, diameter)) Dim path As GraphicsPath = New GraphicsPath() ' top left path.AddArc(arcrect, 180, 90) ' top right arcrect.X = rect.Right - diameter path.AddArc(arcrect, 270, 90) ' bottom right arcrect.Y = rect.Bottom - diameter path.AddArc(arcrect, 0, 90) ' bottom left arcrect.X = rect.Left path.AddArc(arcrect, 90, 90) path.CloseFigure() Return path End Function End Class
sparrow1





Reply With Quote