Infragistics Ultragrid - 组合框作为列

发布于 2024-12-02 08:16:47 字数 710 浏览 0 评论 0原文

我对 Infragistics 的 UltraGrid 控件有疑问。我创建了一个包含一些值的 ultracombobox:

 UltraCombo ultraComboPaneel = new UltraCombo();
        ultraComboPaneel.DataSource = articleList;
        ultraComboPaneel.ValueMember = "ArticleID";
        ultraComboPaneel.DisplayMember = "Name";

现在我有一个 UltraGrid,我想将 ultraCombo 放入一个单元格中,这样我就可以选择 ultracombo 的一项作为单元格值。我在代码和超网格设计器中都尝试过,但我似乎找不到办法。

你们有什么想法吗?如果需要,可以提供更多信息

编辑:

我发现一些东西,就像

UltraGridColumn ugc = ultraGridTypePaneel.DisplayLayout.Bands[0].Columns.Add("combo");
ultraGridTypePaneel.DisplayLayout.Bands[0].Columns["combo"].EditorControl = ultraComboPaneel;

我觉得我走在正确的路上,但它仍然没有显示在屏幕上......

I have a problem with the UltraGrid control from Infragistics. I have created a ultracombobox with a few values in it:

 UltraCombo ultraComboPaneel = new UltraCombo();
        ultraComboPaneel.DataSource = articleList;
        ultraComboPaneel.ValueMember = "ArticleID";
        ultraComboPaneel.DisplayMember = "Name";

Now I have an UltraGrid, and I want to put the ultraCombo in a cell so I can choose one of the items of the ultracombo as a cell value. I tried it both in code and in the ultragrid designer but i can't seem to find a way to do it.

Any of you got an idea? More information can be provided if needed

Edit:

I found something like

UltraGridColumn ugc = ultraGridTypePaneel.DisplayLayout.Bands[0].Columns.Add("combo");
ultraGridTypePaneel.DisplayLayout.Bands[0].Columns["combo"].EditorControl = ultraComboPaneel;

I feel I'm on the right way but it is still not showing on the screen...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

白鸥掠海 2024-12-09 08:16:47

UltraCombo 提供了大量的功能。如果您需要的只是能够从列表中选择一个项目,您可能会发现网格的 ValueLists 提供了更好的解决方案。

下面是一些可以帮助您入门的代码:

    private void myGrid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
    {
        const string colorValueList = @"ColorValueList";

        if (!e.Layout.ValueLists.Exists(colorValueList))
        {
            ValueList svl = e.Layout.ValueLists.Add(colorValueList);
            svl.ValueListItems.Add(1, "Red");
            svl.ValueListItems.Add(2, "Green");
            svl.ValueListItems.Add(3, "Blue");
        }
        e.Layout.Bands[0].Columns["Color"].ValueList = e.Layout.ValueLists[colorValueList];
    }

The UltraCombo provides a great deal of functionality. If all you need is the ability to choose an item from a list, you might find the grid's ValueLists provide a better solution.

Here's some code to get you started:

    private void myGrid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
    {
        const string colorValueList = @"ColorValueList";

        if (!e.Layout.ValueLists.Exists(colorValueList))
        {
            ValueList svl = e.Layout.ValueLists.Add(colorValueList);
            svl.ValueListItems.Add(1, "Red");
            svl.ValueListItems.Add(2, "Green");
            svl.ValueListItems.Add(3, "Blue");
        }
        e.Layout.Bands[0].Columns["Color"].ValueList = e.Layout.ValueLists[colorValueList];
    }
乖乖公主 2024-12-09 08:16:47

您可以在下面的链接中找到一些可用于将 DropDown 放入 UltraGrid 单元格中的方法:

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7841

返回到您当前的代码片段 - 你就快到了:

首先,你应该将 UltraCombo 的绑定上下文设置为 UltraCombo 将使用的形式的 BindingContext,如下所示:
ultraComboPaneel.BindingContext = this.BindingContext;

请注意,应在将控件设置为 EditorControl 之前设置绑定上下文。我注意到的另一件事是,该属性当前已更改为 EditorComponent,因此我相信您正在使用旧版本的 Infragistics 组件。但是,您仍然应该能够使用相同的方法。我创建了一个小代码片段,用代码显示了上述内容:

public partial class Form1 : Form
{
    UltraCombo uc;
    public Form1()
    {
        InitializeComponent();
        DataTable dt = new DataTable();
        dt.Columns.Add("Int", typeof(int));
        dt.Rows.Add(1);
        dt.Rows.Add(1);
        dt.Rows.Add(1);

        DataTable dtt = new DataTable();
        dtt.Columns.Add("Int", typeof(int));
        dtt.Rows.Add(2);
        dtt.Rows.Add(2);
        dtt.Rows.Add(2);

        uc = new UltraCombo();
        uc.BindingContext = this.BindingContext;
        uc.DataSource = dtt;

        ultraGrid1.DataSource = dt.DefaultView;
    }

    private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
    {
        e.Layout.Bands[0].Columns[0].EditorComponent = uc;
    }
}

希望这会有所帮助。

You could find at the link below some approaches that you could use to put a DropDown into a UltraGrid cell:

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7841

Going back to your current code snippet - you are almost there:

First you should set the binding context of your UltraCombo to the BindingContext of the form the your UltraCombo will be used like:
ultraComboPaneel.BindingContext = this.BindingContext;

Please note that setting binging context should happen prior setting your control to be EditorControl. One more thing that I noticed is that the property currently is changed to EditorComponent so I believe that you are using older version of the Infragistics components. However you should still be able to use the very same approach. I have created small code snippet showing the above with code:

public partial class Form1 : Form
{
    UltraCombo uc;
    public Form1()
    {
        InitializeComponent();
        DataTable dt = new DataTable();
        dt.Columns.Add("Int", typeof(int));
        dt.Rows.Add(1);
        dt.Rows.Add(1);
        dt.Rows.Add(1);

        DataTable dtt = new DataTable();
        dtt.Columns.Add("Int", typeof(int));
        dtt.Rows.Add(2);
        dtt.Rows.Add(2);
        dtt.Rows.Add(2);

        uc = new UltraCombo();
        uc.BindingContext = this.BindingContext;
        uc.DataSource = dtt;

        ultraGrid1.DataSource = dt.DefaultView;
    }

    private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
    {
        e.Layout.Bands[0].Columns[0].EditorComponent = uc;
    }
}

Hope this helps.

落花随流水 2024-12-09 08:16:47

我改用 Ultra Dropdown。

dim udd As UltraDropDown

udd = New UltraDropDown

    With udd
        'add data binding or value list items here
    End With


    Me.ultragrid.DisplayLayout.Bands(0).Columns("Column Name").ValueList = udd

关键是将ultra网格列的“值列表”分配给Drop down控件的最后一行。

I use the Ultra Dropdown instead.

dim udd As UltraDropDown

udd = New UltraDropDown

    With udd
        'add data binding or value list items here
    End With


    Me.ultragrid.DisplayLayout.Bands(0).Columns("Column Name").ValueList = udd

The key is the last line that assigns the "Value List" of the ultra grid column to the Drop down control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文