首先需要一个可绑定实体

[Serializable]
    public class TreeNodeModel
    {
        private Image _nodePic;
        /// <summary>
        /// 设置图标
        /// </summary>
        public Image NodelPic
        {
            get { return _nodePic; }
            set { _nodePic = value; }
        }
        /// <summary>
        /// 设置名称
        /// </summary>
        public string NodeText { get; set; }
        private List<TreeNodeModel> _nodes = new List<TreeNodeModel>();
        /// <summary>
        /// 子节点
        /// </summary>
        public List<TreeNodeModel> Nodes
        {
            get { return _nodes; }
            set { _nodes = value; }
        }
        /// <summary>
        /// 数据源
        /// </summary>
        public object DataSource { get; set; }
        private Color m_NodeBackgroundColor = Color.Empty;
        /// <summary>
        /// 背景颜色(默认白色)
        /// </summary>
        public Color NodeBackgroundColor
        {
            get { return m_NodeBackgroundColor; }
            set { m_NodeBackgroundColor = value; }
        }

        private bool m_canExpand = true;
        /// <summary>
        /// 是否可展开
        /// </summary>
        public bool CanExpand
        {
            get { return m_canExpand; }
            set
            {
                m_canExpand = value;
            }
        }
        private int? _nodeHeight = null;
        /// <summary>
        /// 节点高度
        /// </summary>
        public int? NodeHeight
        {
            get { return _nodeHeight; }
            set { _nodeHeight = value; }
        }
        private bool _isEventClick = true;
        /// <summary>
        /// 是否触发点击事件
        /// </summary>
        public bool IsEventClick
        {
            get { return _isEventClick; }
            set { _isEventClick = value; }
        }

        private Color nodeForeColor=Color.Empty;
        /// <summary>
        /// 字体颜色
        /// </summary>
        public Color NodeForeColor
        {
            get { return nodeForeColor; }
            set { nodeForeColor = value; }
        }
    }
View Code

相关文章:

  • 2022-12-23
  • 2021-09-10
  • 2021-06-01
  • 2021-09-14
  • 2021-06-14
  • 2022-01-03
猜你喜欢
  • 2021-11-07
  • 2021-12-31
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案