1

I want to make a round button for a media player, as well as these buttons: buttons

I have managed to do it with the following code:

public partial class UserControl1 : Button
{
    public UserControl1()
    {
        InitializeComponent();
        FlatStyle = FlatStyle.Flat;
        FlatAppearance.BorderSize = 0;
        BackColor = Color.Red;
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        GraphicsPath grPath = new GraphicsPath();
        grPath.AddEllipse(0, 0, ClientSize.Width-3, ClientSize.Height-3);
        this.Region = new Region(grPath);
        base.OnPaint(e);
    }
}

But the round shape looks bad, as if it was pixelated or as if it did not have good quality, I attached a photo:

photo

I would like you to help me with code in C # or Visual Basic, for Windows Form.

Klaus Gütter
  • 11,151
  • 6
  • 31
  • 36
  • See this answer https://stackoverflow.com/questions/33878184/c-sharp-how-to-make-smooth-arc-region-using-graphics-path – TheGeneral Feb 07 '19 at 03:53
  • There's the chance that, if you want a round Button, you don't actually want a *Button* but a Control that acts like a Button. Using bitmaps that simulate the button states. See [this translucent control](https://stackoverflow.com/a/51435842/7444103). If you can paint a couple of bitmaps instead of an ellipsis in the center of it, you can then build on it. The borders, if any, can be reproduced using slighly eccentric ellipsis. Use `e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;` everywhere. `Interpolation` and `Composition` are inconsequential here. – Jimi Feb 07 '19 at 05:00
  • Take a look at [Toggle Switch Control in Windows Forms](https://stackoverflow.com/q/38431674/3110834) or [Circular RadioButton List in Windows Forms](https://stackoverflow.com/a/38390028/3110834) – Reza Aghaei Feb 07 '19 at 06:11

0 Answers0