예제 #1
0
        private void Listbox_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            ThisIndexHasBeenChangedProgrammatically = -1;
            if (Listbox.SelectedIndex == -1) //true when nothing is selected
            {
            }
            else if (!CheckIfThumbMouseButtonsHaveBeenPressed(e))
            {
                if (Listbox.Items.Count > 0)
                {
                    Listbox.MouseDown -= Listbox_MouseDown;
                    _mouseUpIndex      = Listbox.IndexFromPoint(Listbox.PointToClient(Cursor.Position));
                    HandleSelectionChange();
                    if (Listbox.SelectedIndex != -1)
                    {
                        OnSelectionReady?.Invoke(this, EventArgs.Empty);
                    }
                }
            }

            Listbox.SelectedIndexChanged += Listbox_SelectedIndexChanged;
        }