4

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

Jelle Capenberghs
  • 794
  • 2
  • 14
  • 30

3 Answers3

3

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];
    }
PaulF
  • 1,133
  • 8
  • 14
3

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.

veljkoz
  • 8,384
  • 8
  • 55
  • 91
Danko Valkov
  • 1,038
  • 8
  • 17
1

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.

Brian Spencer
  • 194
  • 2
  • 7