Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4549392
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:21:15+00:00 2026-05-21T16:21:15+00:00

I need help on how to add curve to each corner. this is my

  • 0

I need help on how to add curve to each corner.

this is my code..

using (Graphics btnG = pevent.Graphics)
using (SolidBrush btnBGSB = new SolidBrush(Color.FromArgb(107, 109, 110)))
using (SolidBrush lblBrush = new SolidBrush(Color.FromArgb(255, 255, 255)))
{
    Rectangle btnBG = new Rectangle(0, 0, this.Width, this.Height);

    btnG.FillRectangle(btnBGSB, btnBG);

    RectangleF lblRec = new RectangleF(0, 0, this.Width - 1, this.Height - 1);
    StringFormat lblSf = new StringFormat();
    lblSf.Alignment = StringAlignment.Center;
    lblSf.LineAlignment = StringAlignment.Center;    

    btnG.DrawString(this.Text, new Font("tahoma", 10.0f, FontStyle.Bold), lblBrush, lblRec, lblSf);
}

this is my 3rd day playing with c#.. just a GUI for my TCPSocket Application.. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:21:16+00:00Added an answer on May 21, 2026 at 4:21 pm

    here is a method I use to make rounded corners:

        public static void DrawRoundedRectangle(this Graphics g, Color color, Rectangle rec, int radius,
                                                RoundedCorners corners)
        {
            using (var b = new SolidBrush(color))
            {
                int x = rec.X;
                int y = rec.Y;
                int diameter = radius * 2;
                var horiz = new Rectangle(x, y + radius, rec.Width, rec.Height - diameter);
                var vert = new Rectangle(x + radius, y, rec.Width - diameter, rec.Height);
    
                g.FillRectangle(b, horiz);
                g.FillRectangle(b, vert);
    
                if ((corners & RoundedCorners.TopLeft) == RoundedCorners.TopLeft)
                    g.FillEllipse(b, x, y, diameter, diameter);
                else
                    g.FillRectangle(b, x, y, diameter, diameter);
    
                if ((corners & RoundedCorners.TopRight) == RoundedCorners.TopRight)
                    g.FillEllipse(b, x + rec.Width - (diameter + 1), y, diameter, diameter);
                else
                    g.FillRectangle(b, x + rec.Width - (diameter + 1), y, diameter, diameter);
    
                if ((corners & RoundedCorners.BottomLeft) == RoundedCorners.BottomLeft)
                    g.FillEllipse(b, x, y + rec.Height - (diameter + 1), diameter, diameter);
                else
                    g.FillRectangle(b, x, y + rec.Height - (diameter + 1), diameter, diameter);
    
                if ((corners & RoundedCorners.BottomRight) == RoundedCorners.BottomRight)
                    g.FillEllipse(b, x + rec.Width - (diameter + 1), y + rec.Height - (diameter + 1), diameter, diameter);
                else
                    g.FillRectangle(b, x + rec.Width - (diameter + 1), y + rec.Height - (diameter + 1), diameter,
                                    diameter);
            }
        }
    
        public enum RoundedCorners
        {
            None = 0x00,
            TopLeft = 0x02,
            TopRight = 0x04,
            BottomLeft = 0x08,
            BottomRight = 0x10,
            All = 0x1F
        }
    

    That way you can specify which corners you want rounded.

    And if you want to have a border around it, use this method:

        public static void DrawRoundedBorder(this Graphics g, Color color, Rectangle rec,
                                             int radius, int borderWidth, RoundedCorners corners)
        {
            using (Bitmap b = new Bitmap(rec.Width, rec.Height))
            using (Graphics gb = Graphics.FromImage(b))
            {
                var gfRec = new Rectangle(0, 0, rec.Width, rec.Height);
                gb.Clear(Color.Green);
    
                gb.DrawRoundedRectangle(color, gfRec, radius, corners);
    
                gfRec.Height -= borderWidth << 1;
                gfRec.Width -= borderWidth << 1;
                gfRec.X += borderWidth;
                gfRec.Y += borderWidth;
                gb.DrawRoundedRectangle(Color.Green, gfRec, radius - borderWidth, corners);
    
                var maskAttr = new ImageAttributes();
                maskAttr.SetColorKey(Color.Green, Color.Green);
    
                g.DrawImage(b, rec, 0, 0, b.Width, b.Height, GraphicsUnit.Pixel, maskAttr);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several questions I need help with. I'll add both my code and
Need help writing a script downloads data from google insight using c# this is
I'm quite new with PHP and need help coding an add script for my
I need help with some gwt (ui:binder) code. I would like to add the
I need help converting this code from C# to Java. public static ulong GetChecksum(byte[]
I do not know where to add ActionListeners/ItemListener and need help: This is the
Need help reworking this php code/logic. Right now, if I have no value for
I need help implementing the code to add a negative or positive button to
I need your help to add some insight into JNI on Android. I've been
OK, I need help. I am trying yo add label values. Ie. buttonpLabel is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.