3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
C#在畫面畫出元件框(使用自訂GroupBox)做出UI版面區隔   資料來源:http://wahahastudynote.blogspot.tw/2013/05/c-groupbox.html   using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Windows.Forms; using System.ComponentModel; namespace SYRIS_BCard_Easy {     class myGroupBox : GroupBox     { //SYRIS_BCard_Easy used //http://wahahastudynote.blogspot.tw/2013/05/c-groupbox.html         private Color _BorderColor = Color.Black;         [Description(“設定或取得外框顏色”)]         public Color BorderColor         {             get { return _BorderColor; }             set { _BorderColor = value; }         }         protected override void OnPaint(PaintEventArgs e)         {             //取得text字型大小             Size FontSize = TextRenderer.MeasureText(this.Text,                                                      this.Font);             //畫框線             Rectangle rec = new Rectangle(e.ClipRectangle.Y,                                           this.Font.Height / 2,                                           e.ClipRectangle.Width – 1,                                           e.ClipRectangle.Height – 1 –                                           this.Font.Height / 2);             e.Graphics.DrawRectangle(new Pen(BorderColor), rec);             //填滿text的背景             e.Graphics.FillRectangle(new SolidBrush(this.BackColor),                 new Rectangle(6, 0, FontSize.Width, FontSize.Height));             //text             e.Graphics.DrawString(this.Text, this.Font,                 new Pen(this.ForeColor).Brush, 6, 0);         }     } }        

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦