How to make Round button in C#

This article demonstrates about how to make a round button in simple windows application and how to use it. .Net does not provide any round button control but you can make a round button with the helps of button class and Ellipse shape.

Round button

This article explain you step by step of making round button using C#.

1. Add a class named ‘RoundButton‘ in your windows application.
2. Create override Paint event like this:

  1. using System;
  2. using System.Drawing.Drawing2D;
  3. using System.Windows.Forms;
  4. public class RoundButton : Button
  5. {
  6.  protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  7.  {
  8.   GraphicsPath grPath = new GraphicsPath();
  9.   grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
  10.         this.Region = new System.Drawing.Region(grPath);
  11.   base.OnPaint(e);
  12.  }
  13. }

3. Build your windows application, you can see a ‘roundbutton‘ control in your toolbox. drag and drop this control to your windows form, set the FlatAppearance property to ‘Flat’ and set the backcolor ‘brown’.

Create Round button

4. You can generate all events like Button control such as if you want to show ‘Welcome’ on click on roundbutton control , you need to create Click event like this:

  1. private void roundButton1_Click(object sender, EventArgs e)
  2.         {
  3.             MessageBox.Show("Welcome");
  4.         }

See also – How to create shaped Windows form

  • kiran

    hi
    i follow the same as it is but i didnot get round button control in my toolbox what should i do
    plz reply me fast
    thanks un advance
     

    • ramu

      hi its working very fine

    • Hirendra Sisodiya

      have you build and rebuild your project?

  • http://www.authorcode.com Hirendra Sisodiya

    you need to build or rebuild your project…

     

  • kiran

    i did it even tough i am not getting that

  • Source

    i did it, rebuild it as well bt in form design i cant see my form instead of it m having this message “to add components of your class, drag them from tool box and use properties window to set their properties. to create method and event of your class click here to swtich to code view”

  • jiangxingfei

    great,but how to create it in windows mobile 6.5 ? ‘GraphicsPath’ is not suport in .Net CF.

  • Thina

    Also FlatAppearence-BorderSize = 0. Thanks