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); base.OnPaint(e); } }
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) { MessageBox.Show("Welcome"); }
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
hi its working very fine
have you build and rebuild your project?
you need to build or rebuild your project…
i did it even tough i am not getting that
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”
great,but how to create it in windows mobile 6.5 ? ‘GraphicsPath’ is not suport in .Net CF.
Also FlatAppearence-BorderSize = 0. Thanks