DevExpress控件使用交流,DevExpress中国社区 售前咨询
当前位置: 首页 > 开发资源 » 常见问答 » 如何在XtraTreelist的每个单元格中添加下拉列表

如何在XtraTreelist的每个单元格中添加下拉列表

作者:mayz   来源:DevExpress   浏览:Loading...次   发布时间:2013-02-21   评论:0条

问题描述:

我正在用Dev的Treelist控件,现在我想在Variancy indicator Column的每个单元格中都添加一个下拉列表,示例代码如下:

[C#]Open in popup window
public partial class Scorecard : DevExpress.XtraEditors.XtraForm
    {
        public Scorecard()
        {
            InitializeComponent();
        }

        private void Scorecard_Load(object sender, EventArgs e)
        {
            CreateColumn(treeList1);
            CreateNode(treeList1);
        }

        private void CreateColumn(TreeList tl)
        {
            Variancy vari = new Variancy();
            tl.BeginUpdate();
            #region selction
            /*tl.Columns.Add();
            tl.Columns[0].Caption = "Perspektif";
            tl.Columns[0].FieldName = "perspektif";
            tl.Columns[0].UnboundType = UnboundColumnType.String;
            tl.Columns[0].VisibleIndex = 0;
            tl.Columns[0].Format.FormatType = DevExpress.Utils.FormatType.None;
            tl.Columns[0].Name = "Perspektif";

            tl.Columns.Add();
            tl.Columns[1].Caption = "Keys Performance Indicator";
            tl.Columns[1].FieldName = "KPI";
            tl.Columns[1].UnboundType = UnboundColumnType.String;
            tl.Columns[1].VisibleIndex = 1;
            tl.Columns[1].Format.FormatType = DevExpress.Utils.FormatType.Custom;
            tl.Columns[1].Name = "KPI";

            tl.Columns.Add();
            tl.Columns[2].FieldName = "VI";
            tl.Columns[2].Caption = "Variance Indicator";
            tl.Columns[2].UnboundType = UnboundColumnType.String;
            tl.Columns[2].Name = "VI";
            tl.Columns[2].Format.FormatType = DevExpress.Utils.FormatType.Custom;
            tl.Columns[2].VisibleIndex = 2;

            tl.Columns.Add();
            tl.Columns[3].FieldName = "Mat";
            tl.Columns[3].Caption = "Matrix";
            tl.Columns[3].UnboundType = UnboundColumnType.String;
            tl.Columns[3].Name = "Mat";
            tl.Columns[3].Format.FormatType = DevExpress.Utils.FormatType.Custom;
            tl.Columns[3].VisibleIndex = 3;

            tl.Columns.Add();
            tl.Columns[4].FieldName = "Weight";
            tl.Columns[4].Caption = "Weight";
            tl.Columns[4].UnboundType = UnboundColumnType.String;
            tl.Columns[4].Name = "Weight";
            tl.Columns[4].Format.FormatType = DevExpress.Utils.FormatType.Custom;
            tl.Columns[4].VisibleIndex = 4;
            tl.Columns[4].SummaryFooter = SummaryItemType.Sum;

            tl.Columns.Add();
            tl.Columns[5].FieldName = "Freq";
            tl.Columns[5].Caption = "Frequency";
            tl.Columns[5].UnboundType = UnboundColumnType.String;
            tl.Columns[5].Name = "Freq";
            tl.Columns[5].Format.FormatType = DevExpress.Utils.FormatType.Custom;
            tl.Columns[5].VisibleIndex = 5;

            tl.Columns.Add();
            tl.Columns[6].FieldName = "Baseline";
            tl.Columns[6].Caption = "Baseline";
            tl.Columns[6].UnboundType = UnboundColumnType.String;
            tl.Columns[6].Name = "Baseline";
            tl.Columns[6].Format.FormatType = DevExpress.Utils.FormatType.Custom;
            tl.Columns[6].VisibleIndex = 6;
            */
            #endregion
            string[] caption = { "Pespektif", "Variancy Indicator", "Matrix", "Weight", "Baseline", "Q1", "Q2", "Q3", "Q4",
                               "Q1", "Q2", "Q3", "Q4"};
                for (int i = 0; i < 13; i++) 
                {
                    tl.Columns.Add();
                    tl.Columns[i].Caption = caption[i];
                    tl.Columns[i].VisibleIndex = i;
                    tl.Columns[i].FieldName = caption[i];
                    tl.Columns[i].Name = caption[i];
                    tl.Columns[i].BestFit();
                    if ((i == 1) || (i == 2) || (i == 0))
                    {
                        tl.Columns[i].UnboundType = UnboundColumnType.String;
                    }
                    else {
                        tl.Columns[i].UnboundType = UnboundColumnType.Decimal;
                        tl.Columns[i].SummaryFooter = SummaryItemType.Sum;
                    }
                    tl.ExpandAll();


                 }
               
            tl.EndUpdate();
                      
        }

        private void CreateNode(TreeList tl)
        {
            tl.BeginUnboundLoad();
            // Create a root node
            TreeListNode parentForRootNodes = null;
            TreeListNode rootNode = tl.AppendNode(new object[] {"Financial"}, parentForRootNodes);
            // Create a child for a root Node
            tl.AppendNode(new object[] { "Division Budget Variance" }, rootNode);
            tl.AppendNode(new object[] { "Training Cost Per Employee" }, rootNode);
            

            TreeListNode rootNode2 = tl.AppendNode(new object[] { "Customer" }, parentForRootNodes);
            tl.AppendNode(new object[] { "Compensation Scheme Gap" }, rootNode2);
            
            TreeListNode rootNode3 = tl.AppendNode(new object[] { "Internal Busniess" }, parentForRootNodes);
            tl.AppendNode(new object[] { "Develpt. Of Manual/Processes" }, rootNode3);
            
            TreeListNode rootNode4 = tl.AppendNode(new object[] { "Learning And Growth" }, parentForRootNodes);
            tl.AppendNode(new object[] { "Training Mandays Per Employee" }, rootNode4);
            
            tl.EndUnboundLoad();
        }

        void treeList1_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                TreeListHitInfo hi = treeList1.CalcHitInfo(new Point(e.X, e.Y));
                TreeListNode newnode = treeList1.AppendNode(new object[] { "New indicator" }, hi.Node);
                treeList1.ExpandAll();
            }
        }

      
      
    }

解决方法:

要在Treelist的每个单元格中添加下拉列表,只需设置TreeListColumn.ColumnEdit属性即可

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/Resources/FAQ-370.html

关键字: XtraTreelist 

相关产品: DXperience Universal Subscription

评论列表

暂无评论

请谈谈你的看法 请使用IE或者Firefox浏览器,暂不支持Chrome!

昵称 不填则默认为游客评论

DevExpress DXperience DXv2 v12

DevExpress DXperience 下载 download

DevExpress购买、价格、授权

慧都控件网为DevExpress界面控件的中国地区唯一正式授权经销商,正版控件销售公司,授权代理商,经销商及合作伙伴。

电话:400-700-1020
        023-66090381

邮箱:sales@evget.com

>>如何选择正规控件购买渠道