C#中TreeView节点的自定义绘制方法
2015-02-03 09:45
501 查看
本文实例讲述了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#中实现在TreeView查找某一节点(两种方法)
- 如何C#中实现在TreeView查找某一节点(两种方法)
- 如何C#中实现在TreeView查找某一节点(两种方法)
- C#中不让TreeView 默认选中第一个节点的方法
- C#实现TreeView节点拖拽的方法
- C#中TreeView实现适合两级节点的选中节点方法
- TreeView节点自定义绘制样式
- 一个很苯的方法实现TreeView节点的动态添加
- C#.NET示例读写xml所有节点的代码实现方法和读取xml节点的数据总结
- C#中treeview 鼠标右键节点选中问题
- C#中TreeView组件使用方法初步
- 使用递归方法获得TreeView中CheckBox选中的节点
- asp.net treeview控件无刷新选择和删除节点的ajax方法
- C#中字符串处理的一些自定义方法
- 一个C#序列化TreeView的方法
- VS2005[C#] 轻轻松松 掌握 TreeView [ 回车展开节点, 鼠标右键,禁止闪屏....]
- 默认选中TreeView某个节点的方法
- C#中如何实现在TreeView模糊查找某一节点
- [★] VS2005[C#] 轻轻松松 掌握 TreeView [ 回车展开节点, 鼠标右键,禁止闪屏....]