2016-07-29 4 views
1

をバインドクリップ: enter image description here
境界線がクリップしていません。
マイコード:は、どのように私はパネルの角を丸く作成しないと私は、私は以下のように問題を抱えている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); 
     } 
} 

答えて

1

あなたはパネルのBackColorを透明にし、このように自分で背景を描くことができます:

e.Graphics.FillPath(Brushes.LightBlue, path); 

あなたが境界線を引く直前。
しかし、WinFormsの透明度は本当に完璧ではありません。コーナーは親コントロールのBackColorを取ります。その下に何かを描画する予定がある場合でも、それをカバーします。

+0

あなたのソリューションは私を助けました!新しいBackgoundプロパティを追加し、パネル内のコントロールの透明に背景色を設定する必要があります。@ zockDoc – Jandy

関連する問題