c# - C# Windows 窗体中的圆角

标签 c# windows winforms

<分区>

我有一个没有边框的窗口。我在网上搜索了圆角,但都带有边框。如何制作 (不带边框) 形式的圆角?有办法吗?

我是c#的新手,所以请解释...

谢谢

最佳答案

试试这个:

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        private static extern IntPtr CreateRoundRectRgn
        (
            int nLeftRect,     // x-coordinate of upper-left corner
            int nTopRect,      // y-coordinate of upper-left corner
            int nRightRect,    // x-coordinate of lower-right corner
            int nBottomRect,   // y-coordinate of lower-right corner
            int nWidthEllipse, // width of ellipse
            int nHeightEllipse // height of ellipse
        );

        public Form1()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.None;
            Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
        }
    }
}

来自这里:Form with Rounded Borders in C#?

关于c# - C# Windows 窗体中的圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18822067/

相关文章:

c# - 如何让 ConfigurationManager 从多个文件加载应用程序设置?

c# - 访问器错误的可访问性

c++ - 如何在 GDI 中转换一个简单的位图

c# - 如何将文本框数据绑定(bind)到列表<>中的特定索引

c# - 表单在不应该关闭的时候关闭

c# - Stream was not readable是在使用readbinary时引起的

c# - FileSystemWatcher 参数异常

android - windows 生成签名 APK 不工作 [react-native]

c# - 从 Windows 打开调制解调器配置对话框 (C#)

winforms - WinForms 的功能区 UI 控件