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

來源:互聯網
上載者:User

標籤:tools   方式   執行個體   lock   pre   arp   else   .com   inter   

本文執行個體講述了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#多線程簡單例子講解C#小數點格式化用法小結C#向線程中傳遞多個參數的解決方案(兩種)
C#中ZipHelper 壓縮和解壓協助類C#實現TreeView節點拖拽的方法C#實現在啟動目錄建立捷徑的方法C#基礎文法:as 運算子使用執行個體

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.