手机
当前位置:查字典教程网 >编程开发 >C#教程 >C#中TreeView节点的自定义绘制方法
C#中TreeView节点的自定义绘制方法
摘要:本文实例讲述了C#中TreeView节点的自定义绘制方法。分享给大家供大家参考。具体如下:if((e.State&TreeNodeState...

本文实例讲述了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节点的自定义绘制方法】相关文章:

c#二进制逆序方法详解

在C#中创建和读取XML文件的实现方法

C#中的yield关键字的使用方法介绍

C#中一些你可能没用过的调试窗口的方法

C#异步调用的好处和方法分享

C# DataGridView添加新行的2个方法

C# 将字节流转换为图片的实例方法

c#创建Graphics对象的三种方法

C# mysql 插入数据,中文乱码的解决方法

C#TreeView 无限级别分类实现方法

精品推荐
分类导航