Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Groupbox Border

Groupbox Border

Groupbox Border

Can you make the groupbox border appear as etched.  I swear I have seen this in many VB .Net screenshots.  I have tried changing the flatstyle property but with no luck.  If I change the flatstyle to standard I get a grey border, but not etched, and any other setting for flatstyle and I get a blue border.  I am using VS .Net 2003.

Any guidance is greatly appreciated.


RE: Groupbox Border

I always thought it was etched.  Maybe its raised.  If you have a link to a screenshot, post it.  I never recall seeing anything differerent on them.

But they could be custom, as a group-box like contronl would be one of the easier ones to create.

RE: Groupbox Border

Thanks for your response!  It was because I had changed the backcolor of my form to a light color.  It seems Visual Studio picks a color that is a good contrast to the forms background color when it can not properly display the etched effect.  I should have figured that out sooner, one of those brain cramps I guesse.


RE: Groupbox Border

The thing that has always bugged me about the GroupBox/Frame is the fact that when the background color is changed is the fact that there is colored space outside of the frame, at the top, by the text.  IMO, it should have been made transparent outside of the border.

RE: Groupbox Border

I agree.  They could have done a lot more with the groupbox.

RE: Groupbox Border

I use the following GroupBox implementation to provide rounded corners and a correctly coloured outside edge.  It might give you what you want...


Imports System.Drawing.Drawing2D

Public Class GroupBoxEx
    Inherits System.Windows.Forms.GroupBox

#Region " Windows Form Designer generated code "

    Public Sub New()

        'This call is required by the Windows Form Designer.

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
            End If
        End If
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container
    End Sub

#End Region

#Region " Properties "

    Private cBorder As Color = Color.Black

    Public Property BorderColor() As Color

            Return cBorder

        End Get

        Set(ByVal Value As Color)

            cBorder = Value


        End Set

    End Property

#End Region

#Region " Paint "

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

        'Draw the border

        Dim p As New Pen(cBorder, 1)

        Dim gp As New GraphicsPath

        gp.AddArc(New Rectangle(0, 9, 16, 16), 180, 90)

        gp.AddArc(New Rectangle(Width - 17, 9, 16, 16), 270, 90)

        gp.AddArc(New Rectangle(Width - 17, Height - 18, 16, 16), 0, 90)

        gp.AddArc(New Rectangle(0, Height - 18, 16, 16), 90, 90)

        gp.AddLine(0, 17, 0, Height - 17)

        e.Graphics.FillPath(New SolidBrush(BackColor), gp)

        e.Graphics.DrawPath(p, gp)

        'Draw the caption

        Dim sf As SizeF = e.Graphics.MeasureString(Text, Font)

        e.Graphics.FillRectangle(New SolidBrush(Color.Transparent), 16, 2, sf.Width, sf.Height + 4)

        e.Graphics.DrawLine(New Pen(BackColor), 16, 9, 16 + sf.Width, 9)

        e.Graphics.DrawString(Text, Font, New SolidBrush(ForeColor), 18, 3)



    End Sub

    Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)

        pevent.Graphics.FillRectangle(New SolidBrush(Parent.BackColor), pevent.ClipRectangle)

    End Sub

#End Region

End Class

RE: Groupbox Border

Thanks SHelton,

I will give it a try!


RE: Groupbox Border

thanks shelton

a star for a star

Christiaan Baes

What a wonderfull world - Louis armstrong

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close