绑定Ultrawintree节点中的下拉列表

时间:2013-07-03 11:02:04

标签: .net vb.net treeview infragistics

我需要在dropdown节点中绑定Ultrawintree。当用户双击节点的单元格时,它应该是可编辑的,因此我需要在dropdown中显示一些值。这样用户就可以选择值并保存/更新。

//代码

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim columnSet As UltraTreeColumnSet = Me.ultraTree1.ColumnSettings.ColumnSets(0)

        '   Use the ActiveCellAppearance to bring attention to the cell
        '   with the input focus
        columnSet.ActiveCellAppearance.BackColor = Color.Red
        columnSet.ActiveCellAppearance.ForeColor = Color.White

        '   Set AllowCellEdit to 'ActivateOnly' so that clicking a cell does
        '   not put in into edit mode immediately
        columnSet.AllowCellEdit = AllowCellEdit.Full

        '   Enable tooltips for cells whose value is not fully visible
        columnSet.TipStyleCell = TipStyleCell.Show
    End Sub

因此,当按钮单击发生时,单元格完全可编辑。但我不需要在单元格中绑定dropdown。这可能吗?

我该怎么做?

注意:我使用的是Infragistics版本 12.1

1 个答案:

答案 0 :(得分:3)

有不同的方法可以解决这个问题。您可以尝试使用UltraTree节点的EditorComponent proeprty。通过这种方式,您可以为节点分配UltraComboEditor控件,这将显示您的下拉值。例如:

this.ultraTree1.Override.ShowEditorButtons = ShowEditorButtons.Always;
        this.ultraTree1.Override.LabelEdit = Infragistics.Win.DefaultableBoolean.True;
        this.ultraTree1.Override.UseEditor = DefaultableBoolean.True;

        DataTable dt = new DataTable("Tabl");
        dt.Columns.Add("X", typeof(Boolean));
        dt.Columns.Add("Y", typeof(String));
        dt.Rows.Add(true, "Test A");
        dt.Rows.Add(false, "Test B");
        dt.Rows.Add(false, "Test C");
        dt.Rows.Add(true, "Test D");

        ultraCombo1.DataSource = dt;
        ultraCombo1.DisplayMember = "Y";
        ultraCombo1.ValueMember = "Y";
        this.ultraTree1.NodeLevelOverrides[0].EditorComponent = ultraCombo1;

如果您使用的是UltraControlContainerEditor,可能会更复杂,也许更有趣的方法。这是我们在UltraTree节点中实现Grid的小样本。例如:

this.ultraTree1.Override.ShowEditorButtons = ShowEditorButtons.Always;
        this.ultraTree1.Override.LabelEdit = Infragistics.Win.DefaultableBoolean.True;
        this.ultraTree1.Override.UseEditor = DefaultableBoolean.True;


        UltraControlContainerEditor ucc = new Infragistics.Win.UltraWinEditors.UltraControlContainerEditor();
        UltraGrid uc = new UltraGrid();
        UltraGrid uc2 = new UltraGrid();

        DataTable dt = new DataTable("Tabl");
        dt.Columns.Add("X", typeof(Boolean));
        dt.Columns.Add("Y", typeof(String));
        dt.Rows.Add(true, "Test A");
        dt.Rows.Add(false, "Test B");
        dt.Rows.Add(false, "Test C");
        dt.Rows.Add(true, "Test D");

        uc2.DataSource = dt;
        uc.DataSource = dt;

        ucc.RenderingControl = uc2;
        ucc.EditingControl = uc;
        this.ultraTree1.NodeLevelOverrides[1].EditorComponent = ucc;

请查看截图以查看结果

enter image description here