C#中TreeView節點的自訂繪製方法

來源:互聯網
上載者:User

標籤:hit   資料   orm   sha   border   margin   span   檔案的   ott   

本文執行個體講述了C#中TreeView節點的自訂繪製方法。分享給大家供大家參考。具體如下:

if ((e.State & TreeNodeStates.Selected) != 0){ //示範為綠底白字 e.Graphics.FillRectangle(Brushes.DeepSkyBlue, e.Node.Bounds); Font nodeFont = e.Node.NodeFont; if (nodeFont == null) nodeFont = ((TreeView)sender).Font; e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));}else{ e.DrawDefault = true;}if ((e.State & TreeNodeStates.Focused) != 0){ using (Pen focusPen = new Pen(Color.Black)) {  focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;  Rectangle focusBounds = e.Node.Bounds;  focusBounds.Size = new Size(focusBounds.Width - 1,  focusBounds.Height - 1);  e.Graphics.DrawRectangle(focusPen, focusBounds); }}

希望本文所述對大家的C#程式設計有所協助。

除聲明外, 跑步客文章均為原創,轉載請以連結形式標明本文地址
  C#中TreeView節點的自訂繪製方法

本文地址:  http://www.paobuke.com/develop/c-develop/pbk23146.html






相關內容C#類比鏈表資料結構的執行個體解析C#實現將javascript檔案編譯成dll檔案的方法C#基於WebBrowser擷取cookie的實現方法通過C#實現自動售貨機介面
C#使用IHttpModule介面修改http輸出的方法C#中List和數組之間轉換的方法C#採用遞迴實現階乘的方法Enterprise Library for .NET Framework 2.0緩衝使用執行個體

C#中TreeView節點的自訂繪製方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.