zl程序教程

您现在的位置是:首页 >  大数据

当前栏目

[转] TreeList 当前节点图标和背景色设置

节点 设置 当前 图标 背景色
2023-09-14 09:02:24 时间

高原之上原文TreeList 选中节点时图标状态和背景色

 

     // 给TreeList加SelectImage
     this.treelArea.SelectImageList = imglCustom;
     // 去掉选中节点时的虚框
     this.treelArea.OptionsView.ShowFocusedFrame;
     // 设置选中时节点的背景色
     this.treelArea.Appearance.FocusedCell.BackColor = System.Drawing.Color.LightSteelBlue;
     this.treelArea.Appearance.FocusedCell.BackColor2 = System.Drawing.Color.SteelBlue;
     this.treelArea.Appearance.FocusedCell.Options.UseBackColor = true;
     // 选中时会把节点中没显示完全的信息全部显示
     this.treelArea.Appearance.FocusedCell.Options.UseTextOptions = true;
     this.treelArea.Appearance.FocusedCell.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;

     /// <summary>
     /// Handles the GetSelectImage event of the treelArea control.
     /// 设置SelectImage的状态,如果是选中的则换成另选中时应该显示的图标
     /// </summary>
     /// <param name="sender">The source of the event.</param>
     /// <param name="e"> instance containing the event data.</param>
      private void treelArea_GetSelectImage(object sender, DevExpress.XtraTreeList.GetSelectImageEventArgs e)
      {          
          e.NodeImageIndex = e.Node.Expanded ? 0 : e.Node.Nodes.Count > 0 ? 1 : 2;

          if (e.FocusedNode)
          {
              e.NodeImageIndex += 3;
          }
      }