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

 我来答
深圳市励拓软件有限公司
2017-04-17 · 互联网+时代高效组织信息化平台
深圳市励拓软件有限公司
汇讯WiseUC企业即时通讯软件是一款以组织内沟通交流为基础,即时通讯为核心,融合办公协同、IT系统集成,帮助企业降低运营成本、提升组织效率的企业级沟通协同平台。
向TA提问
展开全部
我正在用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属性即可
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式