如何在XtraTreelist的每个单元格中添加下拉列表
推荐于2016-10-27 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517184
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信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属性即可
[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属性即可
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询