Hi!
I have the following code that fills-in the combo datasource from an enumelation.
Private Function FillComboWithEnum(Of EType)(ByVal combo As UltraCombo) As UltraDataSource
Dim dataSource As New UltraDataSource Dim enumType = GetType(EType) dataSource.Band.Columns.Add(VALUE_NAME, enumType) dataSource.Band.Columns.Add(TEXT_NAME, GetType(String)) Dim enums As Array enums = [Enum].GetValues(enumType) For Each item In enums Dim ienum As [Enum] = CType(item, [Enum]) Dim stringValue = ienum.GetStringValue() If String.IsNullOrEmpty(stringValue) Then stringValue = ienum.ToString() End If dataSource.Rows.Add(New Object() {ienum, stringValue}) Next item combo.DataSource = dataSource combo.ValueMember = VALUE_NAME combo.DisplayMember = TEXT_NAME combo.DisplayLayout.Bands(0).Columns(0).Hidden = True Return dataSource End Function
So, everything works good, but the combo now have 2 columns. I want to hide the value column-the first column).
But when I run the code, I have an exception, saying that index out of range or key not not found. Is not found because there is any column in the DisplayLayoutBand. Why??
DataSource have 2 columns, but why don't the DisplayLayout band !!?
as I set multiple times the DataSource, I thought that the event InitializeLayout is raised only once... )
You must be trying to reference the column too early. Use the InitializeLayout event.