1

In this previous question, soulblazer and TaW both offered solutions and provided screenshots, for creating rounded button corners.

Rounded edges in button C# (WinForms)

Both of these screenshots show that the top-left corner is well-rounded, the top-right and bottom-left corners slightly less so, and the bottom-right corner less still.

I can't see anything in the logic that should cause this behaviour but I've had the same experience. Is this just a quirk of how Winforms are displayed or is there some way around it?

  • To create a round rectangle region, I ended up using [CreateRoundRectRgn](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createroundrectrgn?WT.mc_id=DT-MVP-5003235). You can see the [example here](https://stackoverflow.com/a/66187652/3110834), or another one [here](https://stackoverflow.com/a/32991419/3110834). – Reza Aghaei Jun 08 '22 at 12:09
  • [This post](https://stackoverflow.com/a/54794097/3110834) using GraphicsPath looks promising too. – Reza Aghaei Jun 08 '22 at 12:12
  • [This one has smooth borders all around](https://stackoverflow.com/a/62778689/7444103). Without a Region (which doesn't support anti-aliasing), only an Opaque Control (no background), deriving from Control, not Button, all painted. -- *Stripped off* of its Designer, so its configuration is somewhat *raw*, but it's functional. – Jimi Jun 08 '22 at 12:12
  • Using a Region instead, but painting inside the Region's bounds of a UserControl: [How to avoid visual artifacts of colored border of zoomable UserControl with rounded corners?](https://stackoverflow.com/a/54794097/7444103). This method can be used in a different scenario. -- BTW, in the answer that TaW posted, the Region is created in the `OnPaint` override, which is not correct. That's weird; for TaW, I mean. – Jimi Jun 08 '22 at 12:21
  • @Jimi: LOL, well is is 7+ years old. Feel free to edit the post to your own standards.. – TaW Jun 08 '22 at 14:14
  • 1
    @TaW Or you could edit your own post to match your own standard (which is pretty high, IMO). Or it could be left as is, a reminiscence of the *past* (I'm not really digging the Cancel colture. Devs should have learned to embrace the Update colture, especially when they find and copy/paste old posts). – Jimi Jun 08 '22 at 14:36
  • I added a note; I'm always embarrassed when I get yet another upvote for this post ;-) – TaW Jun 08 '22 at 15:18
  • Thanks all for your comments. @Reza any tips on making your RoundCornerControl behave like a button? – ShaunHunter Jun 08 '22 at 16:55
  • I woke up with the bright idea to make it inherit from Button instead of Control. I need to set FlatStyle.Flat for it to look right. Thank you for this solution. If you want to post it as an answer I'll accept it but really this should be marked as a duplicate of Andrey's question. – ShaunHunter Jun 09 '22 at 08:52

0 Answers0