WinForm------TreeList修改节点图标和按钮样式
2016-09-02 17:15
274 查看
转载:
1.修改节点图标
(1)拖入TreeList控件(这里如何加载数据就不多说了哈)和ImageLIst控件
a.给ImageList添加图像
b.修改TreeList控件的属性
(2).在属性栏找到TreeList控件的CustomDrawNodeImages事件,并添加以下代码
(3)完成
2.修改按钮样式
在TreeList控件属性栏找到CustomDrawNodeButton事件,并添加以下代码
https://documentation.devexpress.com/#WindowsForms/DevExpressXtraTreeListTreeList_CustomDrawNodeButtontopic
1.修改节点图标
(1)拖入TreeList控件(这里如何加载数据就不多说了哈)和ImageLIst控件
a.给ImageList添加图像
b.修改TreeList控件的属性
(2).在属性栏找到TreeList控件的CustomDrawNodeImages事件,并添加以下代码
private void treeList1_CustomDrawNodeImages(object sender, DevExpress.XtraTreeList.CustomDrawNodeImagesEventArgs e) { if (e.Node.Nodes.Count > 0) { if (e.Node.Expanded) { e.SelectImageIndex = 2; return; } e.SelectImageIndex = 1; } else { e.SelectImageIndex = 0; } }
(3)完成
2.修改按钮样式
在TreeList控件属性栏找到CustomDrawNodeButton事件,并添加以下代码
private void treeList1_CustomDrawNodeButton(object sender, DevExpress.XtraTreeList.CustomDrawNodeButtonEventArgs e) { Rectangle rect = Rectangle.Inflate(e.Bounds, 0, -2); // painting background Brush backBrush = new LinearGradientBrush(rect, Color.Blue, Color.LightSkyBlue, LinearGradientMode.ForwardDiagonal); //填充指定矩形内部 e.Graphics.FillRectangle(backBrush, rect); //绘画3D边框 ControlPaint.DrawBorder3D(e.Graphics, rect, Border3DStyle.RaisedOuter); //要显示的图画 string displayCharacter = e.Expanded ? "-" : "+"; //水平,垂直居中 StringFormat outCharacterFormat = new StringFormat(); outCharacterFormat.Alignment = StringAlignment.Center; outCharacterFormat.LineAlignment = StringAlignment.Center; //绘画图标 e.Graphics.DrawString(displayCharacter, new Font("Verdana", 8, FontStyle.Bold), new SolidBrush(Color.White), rect, outCharacterFormat); // 禁止默认的图标显示 e.Handled = true; }
相关文章推荐
- iOS开发之Swift标签栏按钮UITabBarItem样式修改(图标文字尺寸,颜色等)
- 修改应用程序的图标和在工具栏添加一个按钮
- 修改Vista开始菜单中的电源按钮图标为关机功能
- 修改file按钮的默认样式实现代码
- openerp学习笔记 视图样式(表格行颜色、按钮,字段只读、隐藏,按钮状态、类型、图标、权限,group边距,聚合[合计、平均],样式)
- ext tree相关知识 动态修改节点小图标
- 只修改input file组件的浏览按钮样式
- BeautyEye主题使用中BETitlePane的标题栏图标按钮个性修改
- flex tree 节点的插入顺序以及图标的修改
- 修改file按钮的样式
- zTree样式的修改,子父节点鼠标悬浮式的样式
- Flex中如何利用defaultLeafIcon样式,去掉Tree叶子节点图标
- TreeList 选中节点时图标状态和背景色
- Flex中如何利用defaultLeafIcon样式去掉Tree叶子节点图标的例子
- c# winform 怎么给程序的按钮上也加上小盾牌图标
- 只修改input file组件的浏览按钮样式
- Winform修改exe默认图标
- 修改upload 按钮 样式
- 【组件修改】winform某个tabcontrol控件的修改--加上关闭按钮
- 【转载】c# winform 怎么给程序的按钮上也加上小盾牌图标