經常我們在去掉 窗體邊框原來系統預設的邊框後 窗體會顯得 有點怪怪的 這就需要自己 添加一個邊框
第一步 添加paint事件
添加新項目後 選中視窗 然後打開屬性視窗選中事件面闆 輕按兩下paint事件 跳轉到 代碼視窗

第二步寫代碼
在paint函數中寫上下面代碼
private void Form1_Paint(object sender, PaintEventArgs e)
{
Rectangle tang = this.ClientRectangle; //擷取視窗矩形 為了下面得到視窗的寬高
Graphics g3 = e.Graphics; //建立一個畫布
Color c3 = Color.FromArgb(46, 204, 113); //聲明一個 顔色
Pen p3 = new Pen(c3); //建立一支畫筆
//g3.SmoothingMode = SmoothingMode.HighQuality; //抗鋸齒 使得線條變柔順 在畫斜線或者曲線的時候使用
//g3.InterpolationMode = InterpolationMode.HighQualityBicubic; //使得畫出來的效果高品質
//g3.CompositingQuality = CompositingQuality.HighQuality; //高品質畫圖
g3.DrawLine(p3, 0, 0, 0, tang.Height-1); //在(0,0)和(tang.Width - 1, 0)這兩點間畫一條直線
g3.DrawLine(p3, 0, tang.Height-1, tang.Width-1, tang.Height-1); //注意必須減1 不然顯示不出來 因為 如果假設視窗的高度是3像素 我們知道(0,0)位置代表 視窗最左上角的像素點 那麼最左下角的像素點應該是(0,2) 而不是(0,3) 因為0,1,2 已經三個像素點了
g3.DrawLine(p3, tang.Width-1, tang.Height-1, tang.Width-1, 0);
g3.DrawLine(p3, tang.Width-1, 0, 0, 0);
}
第三步 效果展示
為了顯示邊框更明顯 我 打開了記事本做 背景