468,469 Members | 2,349 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,469 developers. It's quick & easy.

How to have a Border with Rounded Corners

Hi,

I have several panels that holds bunch of controls with information on
my forms. My form has background image property set to an image that
has borders defining where my panel comes and that border is rounded
so when I set my panels border stile to none, the panel appear to have
the rounded border (that comes from the forms background image.

This looks really nice, but the problem is that my forms can not be
resizable then, since the background image is of fixed size.

How can I draw a border with rounded corners around my panel or other
controls and make it looks nice even when form is resized ?

Any help will be appreciated.
_dino_
Nov 21 '05 #1
2 6538
Hi,

I had this code kindly posted for me in this group a while back and it gives
curved corners to a form. I think something similar will work for Controls.

Private Sub BaseForm_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Draw Form

If Not Me.DesignMode Then 'Just learnt this today!!

Me.FormBorderStyle = FormBorderStyle.None
Me.StartPosition = FormStartPosition.CenterScreen
Me.Size = New Size(800, 500)

Dim p As New System.Drawing.Drawing2D.GraphicsPath

Dim CurveSize As Int32 = 250

p.StartFigure()

p.AddArc(New Rectangle(0, 0, CurveSize, CurveSize), 180, 90)

p.AddLine(CurveSize, 0, Me.Width - CurveSize, 0)

p.AddArc(New Rectangle(Me.Width - CurveSize, 0, CurveSize,
CurveSize), -90, 90)

p.AddLine(Me.Width, CurveSize, Me.Width, Me.Height - CurveSize)

p.AddArc(New Rectangle(Me.Width - CurveSize, Me.Height -
CurveSize, CurveSize, CurveSize), 0, 90)

p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)

p.AddArc(New Rectangle(0, Me.Height - CurveSize, CurveSize,
CurveSize), 90, 90)

p.CloseFigure()

Me.Region = New Region(p)

Me.BackColor = Color.Teal

p.Dispose()

end if

End Sub
--

Rod Gill
Project MVP
Visit www.msproject-systems.com for Project Companion Tools and more
"Dino Buljubasic" <di**@noplacelikehome.com> wrote in message
news:ki********************************@4ax.com...
Hi,

I have several panels that holds bunch of controls with information on
my forms. My form has background image property set to an image that
has borders defining where my panel comes and that border is rounded
so when I set my panels border stile to none, the panel appear to have
the rounded border (that comes from the forms background image.

This looks really nice, but the problem is that my forms can not be
resizable then, since the background image is of fixed size.

How can I draw a border with rounded corners around my panel or other
controls and make it looks nice even when form is resized ?

Any help will be appreciated.
_dino_

Nov 21 '05 #2
Thanks Rod,
I appreciate your help. I will give it a try, it seams to be good.
_dion_

On Sat, 7 May 2005 15:20:36 +1200, "Rod Gill" <rod AT project-systems
DOT co DOT nz> wrote:
Hi,

I had this code kindly posted for me in this group a while back and it gives
curved corners to a form. I think something similar will work for Controls.

Private Sub BaseForm_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Draw Form

If Not Me.DesignMode Then 'Just learnt this today!!

Me.FormBorderStyle = FormBorderStyle.None
Me.StartPosition = FormStartPosition.CenterScreen
Me.Size = New Size(800, 500)

Dim p As New System.Drawing.Drawing2D.GraphicsPath

Dim CurveSize As Int32 = 250

p.StartFigure()

p.AddArc(New Rectangle(0, 0, CurveSize, CurveSize), 180, 90)

p.AddLine(CurveSize, 0, Me.Width - CurveSize, 0)

p.AddArc(New Rectangle(Me.Width - CurveSize, 0, CurveSize,
CurveSize), -90, 90)

p.AddLine(Me.Width, CurveSize, Me.Width, Me.Height - CurveSize)

p.AddArc(New Rectangle(Me.Width - CurveSize, Me.Height -
CurveSize, CurveSize, CurveSize), 0, 90)

p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)

p.AddArc(New Rectangle(0, Me.Height - CurveSize, CurveSize,
CurveSize), 90, 90)

p.CloseFigure()

Me.Region = New Region(p)

Me.BackColor = Color.Teal

p.Dispose()

end if

End Sub


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Pierre Jelenc | last post: by
2 posts views Thread by meltedown | last post: by
8 posts views Thread by TheCornjerker | last post: by
5 posts views Thread by Stuart Ferguson | last post: by
reply views Thread by eggsurplus | last post: by
2 posts views Thread by raknin | last post: by
6 posts views Thread by moondaddy | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.