这是使表格圆角化的源代码,
但我怎样才能在每个角落设置自己的半径?
[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, // height of ellipse
int nHeightEllipse // width of ellipse
);
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, 405, 546, 20, 20));
我只想左上角四舍五入。
答案 0 :(得分:0)
您可以自己创建。
使用GraphicsPath
,然后使用constructor overload转换为Region
,GraphicsPath
using (GraphicsPath gfxPath = new GraphicsPath())
{
int d = CornerRadius * 2;
gfxPath.AddArc(Bounds.Left, Bounds.Top, d, d, 180, 90);
gfxPath.AddLine(Bounds.Right, Bounds.Top, Bounds.Right, Bounds.Bottom);
gfxPath.AddLine(Bounds.Right, Bounds.Bottom, Bounds.Left, Bounds.Bottom);
gfxPath.CloseAllFigures();
region = new Region(gfxPath);
}