DevExpress設(shè)置TreeList圖片節(jié)點(diǎn)背景色的方法
本文實(shí)例展示了DevExpress設(shè)置TreeList圖片節(jié)點(diǎn)背景色的方法,在項(xiàng)目開(kāi)發(fā)中有一定的應(yīng)用價(jià)值,具體方法如下所示:
主要功能代碼如下:
/// <summary>
/// 設(shè)置圖片節(jié)點(diǎn)的背景色
/// 說(shuō)明:在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)
{
}
}
代碼運(yùn)行效果如下圖所示:

- DevExpress TreeList 常見(jiàn)問(wèn)題解決方法
- DevExpress之TreeList用法實(shí)例總結(jié)
- DevExpress實(shí)現(xiàn)TreeList向上遞歸獲取公共父節(jié)點(diǎn)的方法
- DevExpress實(shí)現(xiàn)TreeList父子節(jié)點(diǎn)CheckState狀態(tài)同步的方法
- DevExpress實(shí)現(xiàn)TreeList按條件隱藏節(jié)點(diǎn)CheckBox的方法
- DevExpress實(shí)現(xiàn)禁用TreeListNode CheckBox的方法
- Devexpress treelist 簡(jiǎn)介
相關(guān)文章
C# 中的 IReadOnlyDictionary 和 IReadOnlyLis
C# WPF實(shí)現(xiàn)的語(yǔ)音播放自定義控件
C# 實(shí)現(xiàn)Eval(字符串表達(dá)式)的三種方法
C#中隱藏TabControl選項(xiàng)卡標(biāo)簽的解決方案
基于C#實(shí)現(xiàn)網(wǎng)絡(luò)爬蟲(chóng) C#抓取網(wǎng)頁(yè)Html源碼

