Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
124
System.NullReferenceException when binding an UltraCombo against data from a Generic.Dictionary collection.
posted

Hi hope someone can help,

 I'm trying to bind an UltraCombo against data from a Generic.Dictionary collection object using the following code in the load event of a composite user control:

 Dim BookingOrderItems As New System.Collections.Generic.Dictionary(Of BookingOrderEnum, String)

With BookingOrderItems

.Add(BookingOrderEnum.Any, "Any")

.Add(BookingOrderEnum.HolidayBeforeTOIL, "TOIL before holiday")

.Add(BookingOrderEnum.TOILBeforeHoliday, "Holiday before TOIL")

End With

With ultracomboBookingOrder

.ValueMember = "Key"

.DisplayMember = "Value"

.DataSource = BookingOrderItems

End With

This results in a System.NullReferenceException at the point where i assign BookingOrderItems object to the data source property.

If i change the above code to use a simple Generic.List of strings as in the following code then the everything works fine.

Dim BookingOrderItems As New System.Collections.Generic.List(Of String)
With BookingOrderItems
.Add("Any")

.Add("TOIL before holiday")

.Add("Holiday before TOIL")

End With

Me.ultracomboBookingOrder.DataSource = BookingOrderItems

I would therefore assume i'm missing something in how i'm going about setting up the binding.

Please excuse any obvious errors in the above code as i'm new to using the UltraCombo.

Thanks for any help,

 Simon.