private void OnListBoxSelectedIndexChanged(object sender, EventArgs e)
{
switch (_listBox.SelectionMode)
{
case SelectionMode.One:
if (_lastSelectedIndex != _listBox.SelectedIndex)
{
_lastSelectedIndex = _listBox.SelectedIndex;
UpdateStateAndPalettes();
_listBox.Invalidate();
OnSelectedIndexChanged(e);
}
break;
case SelectionMode.MultiSimple:
case SelectionMode.MultiExtended:
if (SelectedIndicesChanged(_lastSelectedColl, _listBox.SelectedIndices))
{
// Clone the selected index collection
_lastSelectedColl = new int[_listBox.SelectedIndices.Count];
_listBox.SelectedIndices.CopyTo(_lastSelectedColl, 0);
UpdateStateAndPalettes();
_listBox.Invalidate();
OnSelectedIndexChanged(e);
}
break;
}
}