This article describes the method of drawing rounded corners by WinForm. Share it for your reference. The specific implementation method is as follows:
using System; using ; using ; using ; using ; using ; using ; using ; using ; using .Drawing2D; namespace AppStartSample { public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { } public void SetWindowRegion() { . FormPath; FormPath = new .(); Rectangle rect = new Rectangle(0, 22, , - 22);// FormPath = GetRoundedRectPath(rect, 30); = new Region(FormPath); } private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius) { int diameter = radius; Rectangle arcRect = new Rectangle(, new Size(diameter, diameter)); GraphicsPath path = new GraphicsPath(); // upper left corner (arcRect, 180, 90); // upper right corner = - diameter; (arcRect, 270, 90); // Lower right corner = - 0; (arcRect, 0, 90); // Lower left corner = ; (arcRect, 90, 90); (); return path; } protected override void OnResize( e) { = null; SetWindowRegion(); } } }
I hope this article will be helpful to everyone's C# programming.