1
我想周圍畫panel.But邊框我有如下問題:
邊界不夾。
我的代碼:如何創建一個圓角面板和剪輯的約束
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int diameter = radius * 2;
Size size = new Size(diameter, diameter);
int w = size.Width-1;
int h = size.Height-1;
Rectangle arc = new Rectangle(bounds.Location.X, bounds.Location.Y, w, h);
GraphicsPath path = new GraphicsPath();
path.AddArc(arc, 180, 90);
arc.X = bounds.Right - diameter;
path.AddArc(arc, 270, 90);
arc.Y = bounds.Bottom- diameter;
path.AddArc(arc, 0, 90);
arc.X = bounds.Left;
path.AddArc(arc, 90, 90);
path.CloseFigure();
GraphicsPath GraphPath = path;
this.Region = new Region(GraphPath);
using (Pen pen = new Pen(Color.Blue, 1)) {
e.Graphics.DrawPath(pen, path);
}
}
您的解決方案幫助了我!我需要添加一個新的Backgound屬性,並將背景顏色設置爲面板@ zockDoc內的控件的透明 – Jandy