標籤: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節點的自訂繪製方法