1、
如果製作圓角窗體,窗體先繼承DOTNETBAR的:public partial class Form2 : DevComponents.DotNetBar.Office2007Form
然後窗體里加上一個DONTERBAR的panel,然後設定panel為fill佔滿整個窗體
然後設定panel的CornerType為Rounded,然後窗體就變為圓角的了: panelEx1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
2、
如果是圓角控制元件就照葫蘆畫瓢,把panel放在控制元件上面,然後設定為fill,再設定panel的CornerType為Rounded就變為圓角控制元件了
DOTNETBAR的button控制元件預設就可以設定為圓角按鈕的
今天弄個了一天最後弄出了圓角窗體,可是不是用DOTNETBAR,原來DOTNETBAR實現不了,以下是本人實現圓角窗體的程式碼
1 /// <summary> 2 /// 重繪窗體為圓角 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void DispenserForm_Paint(object sender, PaintEventArgs e) 7 { 8 Form form = ((Form)sender); 9 List<Point> list = new List<Point>(); 10 int width = form.Width; 11 int height = form.Height; 12 13 //左上 14 list.Add(new Point(0, 5)); 15 list.Add(new Point(1, 5)); 16 list.Add(new Point(1, 3)); 17 list.Add(new Point(2, 3)); 18 list.Add(new Point(2, 2)); 19 list.Add(new Point(3, 2)); 20 list.Add(new Point(3, 1)); 21 list.Add(new Point(5, 1)); 22 list.Add(new Point(5, 0)); 23 //右上 24 list.Add(new Point(width - 5, 0)); 25 list.Add(new Point(width - 5, 1)); 26 list.Add(new Point(width - 3, 1)); 27 list.Add(new Point(width - 3, 2)); 28 list.Add(new Point(width - 2, 2)); 29 list.Add(new Point(width - 2, 3)); 30 list.Add(new Point(width - 1, 3)); 31 list.Add(new Point(width - 1, 5)); 32 list.Add(new Point(width - 0, 5)); 33 //右下 34 list.Add(new Point(width - 0, height - 5)); 35 list.Add(new Point(width - 1, height - 5)); 36 list.Add(new Point(width - 1, height - 3)); 37 list.Add(new Point(width - 2, height - 3)); 38 list.Add(new Point(width - 2, height - 2)); 39 list.Add(new Point(width - 3, height - 2)); 40 list.Add(new Point(width - 3, height - 1)); 41 list.Add(new Point(width - 5, height - 1)); 42 list.Add(new Point(width - 5, height - 0)); 43 //左下 44 list.Add(new Point(5, height - 0)); 45 list.Add(new Point(5, height - 1)); 46 list.Add(new Point(3, height - 1)); 47 list.Add(new Point(3, height - 2)); 48 list.Add(new Point(2, height - 2)); 49 list.Add(new Point(2, height - 3)); 50 list.Add(new Point(1, height - 3)); 51 list.Add(new Point(1, height - 5)); 52 list.Add(new Point(0, height - 5)); 53 54 Point[] points = list.ToArray(); 55 56 GraphicsPath shape = new GraphicsPath(); 57 shape.AddPolygon(points); 58 59 //將窗體的顯示區域設為GraphicsPath的例項 60 form.Region = new System.Drawing.Region(shape); 61 }