手机
当前位置:查字典教程网 >编程开发 >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#中调用命令行cmd开启wifi热点的实例代码

C#调用Java类的实现方法

C#中Web.Config加密与解密的方法

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

VB.NET中Caching的使用方法

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

C#图片压缩的实现方法

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

C#中using的三种用法

C# 语音功能的实现方法

精品推荐
分类导航