DOTNETBAR制作圓角窗體和圓角控件代碼實(shí)例
1、如果制作圓角窗體,窗體先繼承DOTNETBAR的:public partial class Form2 : DevComponents.DotNetBar.Office2007Form
然后窗體里加上一個(gè)DONTERBAR的panel,然后設(shè)置panel為fill占滿整個(gè)窗體
然后設(shè)置panel的CornerType為Rounded,然后窗體就變?yōu)閳A角的了: panelEx1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
2、如果是圓角控件就照葫蘆畫瓢,把panel放在控件上面,然后設(shè)置為fill,再設(shè)置panel的CornerType為Rounded就變?yōu)閳A角控件了
DOTNETBAR的button控件默認(rèn)就可以設(shè)置為圓角按鈕的
今天弄個(gè)了一天最后弄出了圓角窗體,可是不是用DOTNETBAR,原來(lái)DOTNETBAR實(shí)現(xiàn)不了,以下是本人實(shí)現(xiàn)圓角窗體的代碼
/// <summary>
/// 重繪窗體為圓角
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DispenserForm_Paint(object sender, PaintEventArgs e)
{
Form form = ((Form)sender);
List<Point> list = new List<Point>();
int width = form.Width;
int height = form.Height;
//左上
list.Add(new Point(0, 5));
list.Add(new Point(1, 5));
list.Add(new Point(1, 3));
list.Add(new Point(2, 3));
list.Add(new Point(2, 2));
list.Add(new Point(3, 2));
list.Add(new Point(3, 1));
list.Add(new Point(5, 1));
list.Add(new Point(5, 0));
//右上
list.Add(new Point(width - 5, 0));
list.Add(new Point(width - 5, 1));
list.Add(new Point(width - 3, 1));
list.Add(new Point(width - 3, 2));
list.Add(new Point(width - 2, 2));
list.Add(new Point(width - 2, 3));
list.Add(new Point(width - 1, 3));
list.Add(new Point(width - 1, 5));
list.Add(new Point(width - 0, 5));
//右下
list.Add(new Point(width - 0, height - 5));
list.Add(new Point(width - 1, height - 5));
list.Add(new Point(width - 1, height - 3));
list.Add(new Point(width - 2, height - 3));
list.Add(new Point(width - 2, height - 2));
list.Add(new Point(width - 3, height - 2));
list.Add(new Point(width - 3, height - 1));
list.Add(new Point(width - 5, height - 1));
list.Add(new Point(width - 5, height - 0));
//左下
list.Add(new Point(5, height - 0));
list.Add(new Point(5, height - 1));
list.Add(new Point(3, height - 1));
list.Add(new Point(3, height - 2));
list.Add(new Point(2, height - 2));
list.Add(new Point(2, height - 3));
list.Add(new Point(1, height - 3));
list.Add(new Point(1, height - 5));
list.Add(new Point(0, height - 5));
Point[] points = list.ToArray();
GraphicsPath shape = new GraphicsPath();
shape.AddPolygon(points);
//將窗體的顯示區(qū)域設(shè)為GraphicsPath的實(shí)例
form.Region = new System.Drawing.Region(shape);
}
相關(guān)文章
C#實(shí)現(xiàn)通過(guò)模板自動(dòng)創(chuàng)建Word文檔的方法
這篇文章主要介紹了C#實(shí)現(xiàn)通過(guò)模板自動(dòng)創(chuàng)建Word文檔的方法,詳細(xì)講述了C#生成Word文檔的實(shí)現(xiàn)方法,是非常實(shí)用的技巧,需要的朋友可以參考下2014-09-09
C#實(shí)現(xiàn)身份證號(hào)碼驗(yàn)證的方法
這篇文章主要介紹了C#實(shí)現(xiàn)身份證號(hào)碼驗(yàn)證的方法,通過(guò)封裝的類文件實(shí)例化調(diào)用實(shí)現(xiàn)了對(duì)身份證號(hào)碼的驗(yàn)證,是非常實(shí)用的技巧,需要的朋友可以參考下2014-11-11
C# 實(shí)現(xiàn)dataGridView選中一行右鍵出現(xiàn)菜單的示例代碼
這篇文章主要介紹了C# 實(shí)現(xiàn)dataGridView選中一行右鍵出現(xiàn)菜單,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-09-09
C#實(shí)現(xiàn)判斷當(dāng)前操作用戶管理角色的方法
這篇文章主要介紹了C#實(shí)現(xiàn)判斷當(dāng)前操作用戶管理角色的方法,涉及C#針對(duì)系統(tǒng)用戶判斷的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08
C#實(shí)現(xiàn)Winform鼠標(biāo)拖動(dòng)窗口大小時(shí)設(shè)定窗口最小尺寸的方法
這篇文章主要介紹了C#實(shí)現(xiàn)Winform鼠標(biāo)拖動(dòng)窗口大小時(shí)設(shè)定窗口最小尺寸的方法,涉及WinForm改變窗口大小時(shí)動(dòng)態(tài)判斷當(dāng)前窗口尺寸的相關(guān)技巧,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2015-11-11
C#實(shí)現(xiàn)利用Windows API讀寫INI文件的方法
這篇文章主要介紹了C#實(shí)現(xiàn)利用Windows API讀寫INI文件的方法,涉及C#針對(duì)ini文件的創(chuàng)建、讀取及寫入等操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07
在.NET?WebService中跨域CORS問(wèn)題的解決方案
在現(xiàn)代的Web應(yīng)用程序開發(fā)中,跨域資源共享(Cross-Origin?Resource?Sharing,?CORS)問(wèn)題是開發(fā)者經(jīng)常遇到的一個(gè)挑戰(zhàn),在這篇博客中,我們將深入探討如何在?.NET?WebService?中解決CORS問(wèn)題,幫助開發(fā)者順利實(shí)現(xiàn)跨域請(qǐng)求,需要的朋友可以參考下2024-05-05

