Bug with multiselect ListBox?

  • Thread starter Thread starter Gianluca
  • Start date Start date
G

Gianluca

This works well on a single selection listbox:

protected override OnMouseDown(...)
{
base.OnMouseDown(...);
MessageBox.Show(this.SelectedIndex.ToString());
}

But on a multiple selection listbox you get a IndexOutOfRange exception.
Which is not documented as a possible exception being thrown by accessing
any of the ListBox properties. Apparently in the OnMouseDown event on a
multiple selection listbox something is in the wrong state and all the
selection properties (SelectedItems, SelectedIndices, SelectedIndex) cannot
be accessed.

Bug or feature?

/Gianluca
 
What I would do is instead of using the general OnMouseDown event i would use
the onSelect event. Just a suggestion
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top