ThermoSight
November 11th, 2005, 06:25 PM
I am having a difficult problem working with a ListBox. Perhaps someone can help.
When the form's constructor is called, it in turn calls on 'PopulateSitesList()' to read in site records and place the name of each in the ListBox. This works well - all records are present and all are selectable. However, manually adding a single additional sitename to the list causes ALL names to be unselectable.
Since I initially submitted this question, I have had to revise my thinking....
The new name *does* appear in the site list, and in the right order (so PopulateSitesList() worked satisfactorily), and the debugger shows that the collection is (or at least, appears to me to be) good.
However, after updating the list box with the additional item, when I click on an item to select it, get_SelectedIndex() returns the correct index value BUT in the very next statement, get_SelectedItem() traps out with an "index out of bounds" exception.
The index returned by get_SelectedIndex() is always correct but get_SelectedItem() always traps out with the "index was outside the bounds of the array" exception. (as mentioned earlier, this does not happen until an item is added).
Bottom line is that the updated listbox LOOKS good, but one cannot select anything: get_SelectedIndex() and get_SelectedItem() do not agree.
interesting problem, huh?
Thanks,
bill
When the form's constructor is called, it in turn calls on 'PopulateSitesList()' to read in site records and place the name of each in the ListBox. This works well - all records are present and all are selectable. However, manually adding a single additional sitename to the list causes ALL names to be unselectable.
Since I initially submitted this question, I have had to revise my thinking....
The new name *does* appear in the site list, and in the right order (so PopulateSitesList() worked satisfactorily), and the debugger shows that the collection is (or at least, appears to me to be) good.
However, after updating the list box with the additional item, when I click on an item to select it, get_SelectedIndex() returns the correct index value BUT in the very next statement, get_SelectedItem() traps out with an "index out of bounds" exception.
The index returned by get_SelectedIndex() is always correct but get_SelectedItem() always traps out with the "index was outside the bounds of the array" exception. (as mentioned earlier, this does not happen until an item is added).
Bottom line is that the updated listbox LOOKS good, but one cannot select anything: get_SelectedIndex() and get_SelectedItem() do not agree.
interesting problem, huh?
Thanks,
bill