标签:style blog http color 使用 os
关键代码:
/// <summary> /// 设置FocusedNode的背景色 /// 说明: /// 在CustomDrawNodeCell事件中使用 /// 示例: /// _curTree.SetFocusedNodeBackColor(Color.Green, Color.PeachPuff, Color.Black, e); /// </summary> /// <param name="tree">TreeList</param> /// <param name="backColor1">起始背景颜色</param> /// <param name="backColor2">结束背景颜色</param> /// <param name="foreBrush">字体颜色</param> /// <param name="e">CustomDrawNodeCellEventArgs</param> public static void SetFocusedNodeBackColor(this TreeList tree, Color backColor1, Color backColor2, Color foreBrush, CustomDrawNodeCellEventArgs e) { if (e.Node == tree.FocusedNode) { Brush _backBrush, _foreBrush; _backBrush = new LinearGradientBrush(e.Bounds, backColor1, backColor2, LinearGradientMode.Horizontal); _foreBrush = new SolidBrush(foreBrush); e.Graphics.FillRectangle(_backBrush, e.Bounds); e.Graphics.DrawString(e.CellText, e.Appearance.Font, _foreBrush, e.Bounds, e.Appearance.GetStringFormat()); e.Handled = true; } }
代码使用:
private void tlLHData_CustomDrawNodeCell(object sender, CustomDrawNodeCellEventArgs e) { TreeList _curTree = sender as TreeList; _curTree.SetFocusedNodeBackColor(Color.Orange, Color.PeachPuff, Color.Black, e); }
代码效果:
[DevExpress]设置FocusedNode的背景色,布布扣,bubuko.com
标签:style blog http color 使用 os
原文地址:http://www.cnblogs.com/Yan-Zhiwei/p/3853342.html