I am binding an ArrayList() to a Listbox control and assigning out an Displaymember and Value on data in the Array. My problem is that I Bind on startup but the Array gets filled after a few function calls. I have code on selectedIndexChanged to check the selectedValue but if the ArrayList is empty it returns an object, once it has data it returns the string I expect. I am still a confused why it runs selectedIndexChanged when the list has no data. Think it may run after I bind the Displaymember but before the value gets assigned:
lbCAT_USER.DataSource = USERS;
// Running here maybe?
lbCAT_USER.DisplayMember = "DisplayString";
// Or Here?
lbCAT_USER.ValueMember = "ID";
Either way my current work around is a try/catch of comparing the SelectedValue to a string and trying to rerun the function.
Simple workaround is maybe a way to check the datatype prior to the if statement? Any ideas of suggestions could be very helpful. Thanks