DevExpress設(shè)置TreeList圖片節(jié)點背景色的方法
更新時間:2014年08月06日 17:35:11 投稿:shichen2014
這篇文章主要介紹了DevExpress設(shè)置TreeList圖片節(jié)點背景色的方法,需要的朋友可以參考下
本文實例展示了DevExpress設(shè)置TreeList圖片節(jié)點背景色的方法,在項目開發(fā)中有一定的應(yīng)用價值,具體方法如下所示:
主要功能代碼如下:
/// <summary>
/// 設(shè)置圖片節(jié)點的背景色
/// 說明:在CustomDrawNodeImages事件中使用
/// </summary>
/// <param name="tree">TreeList</param>
/// <param name="e">CustomDrawNodeImagesEventArgs</param>
/// <param name="builderBackColorHandler">委托</param>
public static void CustomImageNodeBackColor(this TreeList tree, CustomDrawNodeImagesEventArgs e, Func<TreeListNode, Color> builderBackColorHandler)
{
TreeListNode _node = e.Node;
Color _backColor = builderBackColorHandler(_node);
e.Graphics.FillRectangle(new SolidBrush(_backColor), e.Bounds);
}
代碼使用方法如下:
private void tlLHData_CustomDrawNodeImages(object sender, CustomDrawNodeImagesEventArgs e)
{
try
{
tlLHData.CustomImageNodeBackColor(e, node =>
{
string _cabId = node.GetKeyID();
CCabInfo _cabInfo = LHDBHelper.GetCabInfo(_cabId);
if (_cabInfo != null)
{
return _cabInfo.CtuOnlineStatus == 1 ? Color.White : Color.LightGray;
}
return Color.White;
});
}
catch (Exception)
{
}
}
代碼運行效果如下圖所示:

相關(guān)文章
C# 中的 IReadOnlyDictionary 和 IReadOnlyLis
C# 中的IReadOnlyDictionary和IReadOnlyList是接口,用于表示只讀的字典和只讀的列表,這些接口提供了對集合的只讀訪問權(quán)限,即不允許對集合進行修改操作,這篇文章主要介紹了C# 中的 IReadOnlyDictionary 和 IReadOnlyList實例詳解,需要的朋友可以參考下2024-03-03
基于C#實現(xiàn)網(wǎng)絡(luò)爬蟲 C#抓取網(wǎng)頁Html源碼
這篇文章主要為大家詳細介紹了基于C#實現(xiàn)網(wǎng)絡(luò)爬蟲的相關(guān)資料,即C#抓取網(wǎng)頁Html源碼,感興趣的小伙伴們可以參考一下2016-03-03

