Infragistics Ultragrid - Combobox as column

Jelle Capenberghs picture Jelle Capenberghs · Sep 1, 2011 · Viewed 25.1k times · Source

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...

Answer

PaulF picture PaulF · Sep 1, 2011

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];
    }