【发布时间】:2013-09-16 06:59:44
【问题描述】:
我有一个没有边框的窗口。我在网上搜索了圆角,但都带有边框。如何制作表格(not with borders) 的圆角?有没有办法做到这一点?
我是c#的新手,请解释一下...
谢谢
【问题讨论】:
我有一个没有边框的窗口。我在网上搜索了圆角,但都带有边框。如何制作表格(not with borders) 的圆角?有没有办法做到这一点?
我是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));
}
}
}
【讨论】:
【讨论】:
我找到了这段代码
为了设计圆角文本框,我开始尝试使用绘制覆盖事件,但不幸的是没有任何结果,这是因为(我假设)文本框是从 Windows 派生的。因此,我尝试改写 WM_PAINT API,得到了预期的结果
http://www.codeproject.com/Articles/17453/Textbox-with-rounded-corners
谢谢
【讨论】: