如题。

解决方案 »

  1.   

    public static GraphicsPath CreateRoundedRectPath( Rectangle rect, int radius )
    {
    GraphicsPath rectPath = new GraphicsPath(); // Add the line on the top:
    rectPath.AddLine( rect.Left + radius, rect.Top, 
    rect.Right - radius, rect.Top );
    // Add the arc at the top right corner:
    rectPath.AddArc( rect.Right - 2 * radius, rect.Top, 
    radius * 2, radius * 2 , 
    270, 90 );
    // Line down the right:
    rectPath.AddLine( rect.Right, rect.Top + radius, 
    rect.Right, rect.Bottom - 10 );
    // Bottom Right quarter circle:
    rectPath.AddArc( rect.Right - radius * 2, rect.Bottom - radius * 2, 
    radius * 2, radius * 2, 
    0, 90 );
    // bottom line:
    rectPath.AddLine( rect.Right - 2 * radius, rect.Bottom , 
    rect.Left + radius, rect.Bottom );
    // Bottom left quarter circle:
    rectPath.AddArc( rect.Left, rect.Bottom - 2 * radius, 
    2 * radius, 2 * radius, 90, 90 );
    // Up the left side:
    rectPath.AddLine( rect.Left, rect.Bottom - radius, 
    rect.Left, rect.Top + radius );
    // Upper left arc:
    rectPath.AddArc( rect.Left, rect.Top, 
    2 * radius, 2 * radius, 180, 90 ); return rectPath;
    }
      

  2.   

    protected override void OnPaintBackground(PaintEventArgs pevent)
    {
    //填充大的圆角矩形框
    Graphics g = pevent.Graphics;
    g.FillRectangle( Brushes.Lime, 0, 0, this.ClientSize.Width, this.ClientSize.Height ); System.Drawing.Drawing2D.GraphicsPath framePath = Utils.CreateRoundedRectPath(this.ClientRectangle, 5 ); using ( System.Drawing.Drawing2D.LinearGradientBrush frameLgb = 
    new System.Drawing.Drawing2D.LinearGradientBrush( this.ClientRectangle,
    Color.SteelBlue, Color.LightBlue, System.Drawing.Drawing2D.LinearGradientMode.Vertical ) )
    {
    g.FillPath( frameLgb, framePath );
    } //填充小的圆角矩形框:文本区
    Rectangle textAreaRectangle = new Rectangle(this.ClientRectangle.Location.X + 5,
    this.ClientRectangle.Location.Y + 5,this.ClientRectangle.Size.Width - 10,
    this.ClientRectangle.Size.Height - 10); System.Drawing.Drawing2D.GraphicsPath textAreaPath = Utils.CreateRoundedRectPath(textAreaRectangle,5);
    g.FillPath( Brushes.White, textAreaPath );
    }