Binding a Dictionary to a combo box = ArgNullEx on "handler"?
I am having a wierd problem with an exception on one of my combo boxes.
Not sure why I didn't notice it before, but I see it now after I re-enabled
catching all CLR exceptions when thrown.
I am getting this exception :
"Value cannot be null. \n Paramter name:handler"
@at System.ComponentModel.ReflectPropertyDescriptor.-
AddValueChanged(Object component, EventHandler handler)
with the following code on the last line, where I assign it as a datasource.
I seem to have the problem even in the immediate window when I do "new BindingSource(n,Nothing)"
or "new BindingSource(n,"")", or anything else. I can just ignore the exception
and everything functions as expected :
Dim n As New System.Collections.Generic.Dictionary(Of Integer, String)
For i As Integer = 2007 To DateTime.Now.Year
n.Add(i, i.ToString)
Next
comboYear.DataSource = New BindingSource(n, Nothing)
Any ideas why this could be happening, or a way around it. I see many examples
of doing it this way, and no one has complained. I also can not seem to
find any reference to this exact error through google, but that could just
broken fingers.
Thanks,
// Andrew
Date:Mon, 20 Aug 2007 20:51:54 +0000 (UTC)
Author:
|