Re: How to have a Border with Rounded Corners



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" <dino@xxxxxxxxxxxxxxxxxxx> wrote in message
news:ki7n71958mo3448o2btsrha95bs43f626a@xxxxxxxxxx
> 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_


.



Relevant Pages

  • How to have a Border with Rounded Corners
    ... My form has background image property set to an image that ... so when I set my panels border stile to none, ... the rounded border (that comes from the forms background image. ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Change border color for a control
    ... border color for a Panel. ... Because when we set the BorderStyle property of the Panel to FixedSingle, ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Round edge panel: edges not smooth
    ... What I Generally do is paint ... Here's an example of code added to a ScrollableControl (Panel without ... //Define the custom Border Region, ... >the graphics path and draw the graphics path border with desired color. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Round edge panel: edges not smooth
    ... "Mick Doherty" ... > paint the parent to the panel, so it appears transparent, and then paint ... > protected override void OnResize ... > //Define the custom Border Region, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Is this possible with CSS?
    ... have to download the graphic file, save it, and use their own image ... between the background and the border. ... I have no idea how to do it unless I use background image ... ... ..Grid td, .Grid th ...
    (comp.infosystems.www.authoring.stylesheets)