DevExpress treeList与GridControl交互

本文介绍如何在C# WinForm项目中使用DevExpress的TreeList控件动态创建节点,同时实现与GridControl的交互。通过示例代码展示了在节点选择时将信息传递给GridControl显示的方法,但提及存在数据源重复添加的问题待解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

近日用到了好几个Dev的控件,现总结一下treeList的使用,另外包含一点和GridControl的交互。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;


namespace DXWindowsApplication1
{
    public partial class TreeListTest : DevExpress.XtraEditors.XtraUserControl
    {
       
        public TreeListTest()
        {
            InitializeComponent();
            InitGridControlDatasource();//创建gridcontrol的数据源
            CreateTreeListControl();//创建列
            CreateTreeNode("产品研发", false);//根节点
            string[] Department = new string[5] { "研发总监","研发一部","研发二部","研发三部","研发四部"};//父节点
            for (int i = 0; i < Department.Length; i++)
            {
                CreateChildNode(Department[i], false, 0,"");
            }
            string[] Phone = { "139****1238", "139****1238", "139****12381", "139****1238", "139****1238" };
            string[] Employee = { "部门经理","AA","BB", "CC", "DD" };//子节点
            for (int i = 0; i < Employee.Length; i++)
            {
                CreateChildNode(Employee[i], false, 2,Phone[i]);
            }
            
        }
        //创建treeList的列
        private void CreateTreeListControl()
        {
            DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repositoryItemCheckEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
            DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn = new DevExpress.XtraTreeList.Columns.TreeList

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值