DevExpress設置FocusedNode配景色的辦法。本站提示廣大學習愛好者:(DevExpress設置FocusedNode配景色的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是DevExpress設置FocusedNode配景色的辦法正文
本文實例講述了DevExpress設置FocusedNode配景色的辦法,很適用的功效,詳細完成辦法以下:
重要功效代碼以下:
/// <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); }
運轉後果以下: