private void HandleKeyDown(object sender, KeyEventArgs e)
{
if (!m_listBox.Visible)
return;
switch (e.KeyCode)
{
case Keys.Up:
try
{
m_changingSelection = true;
m_listBox.SelectedIndex = Math.Max(m_listBox.SelectedIndex - 1, 0);
m_listBox.ScrollHighlightIntoView();
}
finally
{
m_changingSelection = false;
}
e.Handled = true;
break;
case Keys.Down:
try
{
m_changingSelection = true;
m_listBox.SelectedIndex = Math.Min(m_listBox.SelectedIndex + 1, m_listBox.Items.Count - 1);
m_listBox.ScrollHighlightIntoView();
}
finally
{
m_changingSelection = false;
}
e.Handled = true;
break;
}
}