I load a grid and bind it to datasource1, then i load an UltraComboBoxEditor and bind it with datasource2. When I run it there are no values in the combobox even though during debugging i can see that there should be two selections:
DataBind Grid:
private void LoadBindingSource(BindingSource bindingSource){ grid.SuspendLayout(); try { if (bindingSource == null) throw new ArgumentNullException("bindingSource"); _gridBindingSource = bindingSource; DataSource = _gridBindingSource; DataBind(); } finally { grid.ResumeLayout(true); }}
public void FormatGrid(IGridColumnFormatter gridColumnFormater) { ... foreach (ColumnFormatItem formatItem in columnFormatItemList) { if (columns.Exists(formatItem.Key) && columns[formatItem.Key].IsBound) { UltraGridColumn column = columns[formatItem.Key]; column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Edit; column.Hidden = false; column.Header.VisiblePosition = formatItem.Order; column.Header.Caption = formatItem.Name; ... if (formatItem.LookupList != null) { var control = new Infragistics.Win.UltraWinEditors.UltraComboEditor(); control.DataSource = formatItem.LookupList; control.DisplayMember = NoteValueSelectionChild.Field.SelectionValue.ToString(); control.ValueMember = NoteValueSelectionChild.Field.NoteValueId.ToString(); switch (formatItem.DisplayType) { case ColumnFormatItem.CellDisplayType.ComboList: column.EditorComponent = control; break; case ColumnFormatItem.CellDisplayType.MultiSelect: control.CheckedListSettings.CheckBoxStyle = CheckStyle.CheckBox; control.CheckedListSettings.CheckBoxAlignment = ContentAlignment.MiddleLeft; control.CheckedListSettings.EditorValueSource = EditorWithComboValueSource.CheckedItems; control.CheckedListSettings.ItemCheckArea = ItemCheckArea.Item; control.CheckedListSettings.ListSeparator = ", "; column.EditorComponent = control; break; } } } } } } }
public void FormatGrid(IGridColumnFormatter gridColumnFormater)
{
...
foreach (ColumnFormatItem formatItem in columnFormatItemList)
if (columns.Exists(formatItem.Key) && columns[formatItem.Key].IsBound)
UltraGridColumn column = columns[formatItem.Key];
column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Edit;
column.Hidden = false;
column.Header.VisiblePosition = formatItem.Order;
column.Header.Caption = formatItem.Name;
if (formatItem.LookupList != null)
var control = new Infragistics.Win.UltraWinEditors.UltraComboEditor();
control.DataSource = formatItem.LookupList;
control.DisplayMember = NoteValueSelectionChild.Field.SelectionValue.ToString();
control.ValueMember = NoteValueSelectionChild.Field.NoteValueId.ToString();
switch (formatItem.DisplayType)
case ColumnFormatItem.CellDisplayType.ComboList:
column.EditorComponent = control;
break;
case ColumnFormatItem.CellDisplayType.MultiSelect:
control.CheckedListSettings.CheckBoxStyle = CheckStyle.CheckBox;
control.CheckedListSettings.CheckBoxAlignment = ContentAlignment.MiddleLeft;
control.CheckedListSettings.EditorValueSource = EditorWithComboValueSource.CheckedItems;
control.CheckedListSettings.ItemCheckArea = ItemCheckArea.Item;
control.CheckedListSettings.ListSeparator = ", ";
}
and sorry for the doube space but hey I just tried everything i could and nothing works. It would help if people could simply copy/paste from VS in here.
so apparently i'm not doing something right with my column settings?
I think you just have to assign a value to the column's ValueList property. In this case you can set it to the return value from the UltraComboEditor's ValueList property (or, equivalently, UltraComboEditor.Items.ValueList).
Attempting to do either throws an exception:
"ValueList.Appearances must be the same as this grid's layout.Appearances."
But this property is read only, I'm unable to get around this. I'm also not sure this is the correct answer. The ValueList property is for when you're using the grid's built-in combo box functionality, but in this case we're using a control and implanting it in the cell/column. But I don't really know this is just the best I can guess.
If you are setting EditorComponent, you don't need to set ValueList.
The problem here is that you are creating the UltraComboEditor in code and you never assign it to any container, so it has no BindingContext. This also means it will never be disposed, so you have a memory leak here.
The easiest way to fix both of these issues is to add the control to the form's Controls collection. That way it will pick up the BindingContext of the form.