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.
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:
- using System;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- public class RoundButton : Button
- protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
- GraphicsPath grPath = new GraphicsPath();
- grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
- this.Region = new System.Drawing.Region(grPath);
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’.
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:
- private void roundButton1_Click(object sender, EventArgs e)