Hi Jack,
I'm afraid I can't reproduce your problem. Does this problem always occ=
ur, even in a blank solution with only a ListBox? Are you doing anythin=
g else you may think could interfere?
I have never encountered this error, and according to google, very few o=
thers as well. If you always get this error, try running the code outsi=
de visual studio and/or in release mode. It may be that Visual Studio h=
as gone corrupt, in which case you might need to reinstall it.
On Sat, 24 Nov 2007 00:50:18 +0100, Jack Jackson <jacknospam@pebbleridge=
[quoted text, click to view] ..com> wrote:
> On Fri, 23 Nov 2007 13:54:26 -0800, Jack Jackson
> <jacknospam@pebbleridge.com> wrote:
>
>> VB2005. I have a ListBox bound to a BindingList that is initially
>> empty. As soon as I add an item to the BindingList, the call to Add
>> throws an exception:
>> InvalidArgument=3DValue of '0' is not valid for 'SelectedIndex'.
>> Parameter name: SelectedIndex
>>
>> The following code demonstrates this:
>>
>> Dim xx As New System.ComponentModel.BindingList(Of String)
>>
>> Me.ListBox1.DataSource =3D xx
>> xx.Add("aa")
>> xx.Add("bb")
>>
>> The exception only occurs on the first add. If I swap the setting of=
>> DataSource and the first Add, it works fine.
>>
>> Can anyone explain what is going on here?
>
> I just noticed that if I continue in the debugger, execution proceeds
> to the next statement. Is that normal? I would expect my application=
> level exception handler to get control on any unhandled exception.
>
> I also just noticed that I now have this same behavior with a combobox=
> in another app. Both of these used to not get exceptions, so I am
> even more confused now.
>
-- =
Happy coding!