如何在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
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/Resources/FAQ-370.html
关键字: XtraTreelist
上一篇: 如何自定义TreeList单元格的工具条
下一篇: XtraTreeList如何绑定父子节点
评论列表
暂无评论
请谈谈你的看法 请使用IE或者Firefox浏览器,暂不支持Chrome!
慧都控件网为DevExpress界面控件的中国地区唯一正式授权经销商,正版控件销售公司,授权代理商,经销商及合作伙伴。
电话:400-700-1020
023-66090381
邮箱:sales@evget.com
相关资源
- XtraCharts入门教程三:绑定图表系列到数据源
- XtraCharts示例三:运行时绑定单个图表系列到外部数据源
- DXCharts入门手册三:使用系列模板自动创建系列
- XtraGrid数据绑定示例一:添加非绑定列
- DevExpress XtraGrid网格获取主、从表行列值的方法
- DevExpress XtraGrid网格控件示例一:指定列编辑器
- DevExpress XtraGrid网格控件示例四:初始化新建行的单元格
- DevExpress XtraGrid网格控件示例六:自定义合并单元格
- DevExpress XtraGrid网格控件示例七:列过滤
- DevExpress XtraGrid网格控件帮助文档:如何隐藏/显示列和Bands
- 使用XtraCharts时,在运行时改变point chart比列
- 如何格式化XtraGrid网格控件中的单元格
- DevExpress XtraGrid网格控件示例:在GridView中编辑合并后的单元格
- ASPxGridView控件常用示例一:添加一个非绑定列
- 如何为XtraGrid列头设置禁用热跟踪功能?
- 在3D 区域图中显示系列标签
- ASPxGridView控件常用示例八:显示列标题的上下文菜单
- 绑定Devexpress Gridview的checkbox列中的数据源
- 禁用ASPxTreeList复选框选项
- 如何自定义TreeList单元格的工具条