예제 #1
0
 private void Listbox_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Left)
     {
         return;
     }
     Listbox.SelectedIndexChanged -= Listbox_SelectedIndexChanged;
     if (Listbox.Items.Count <= 0)
     {
         return;
     }
     OnSelectionNotReady?.Invoke(this, EventArgs.Empty);
     if (CheckIfThumbMouseButtonsHaveBeenPressed(e))
     {
         return;
     }
     _mouseDownIndex = Listbox.IndexFromPoint(e.Location);
     //if selection starts beneath the listbox, we don't want anything selected,
     //since the selection is "buggy" and doesn't select as one would assume.
     if (_mouseDownIndex != -1)
     {
         return;
     }
     if (Listbox.SelectedIndex != -1)
     {
         Listbox.SetSelected(Listbox.SelectedIndex, false);
     }
     Listbox.Enabled = false;
     Listbox.Enabled = true;
 }