Beispiel #1
0
        private void ListBoxItemsMouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }
            var loc = ListBoxItems.PointToScreen(new Point(e.X, e.Y));

            for (int i = 0; i < ListBoxItems.Items.Count; i++)
            {
                var rec = ListBoxItems.GetItemRectangle(i);
                if (rec.X <= e.X && (rec.X + rec.Width) >= e.X && rec.Y <= e.Y && (rec.Y + rec.Height) >= e.Y)
                {
                    ItemContextMenu.Items[0].Enabled = true;
                    ItemContextMenu.Items[2].Enabled = true;
                    ItemContextMenu.Items[3].Enabled = true;
                    ItemContextMenu.Items[4].Enabled = true;
                    ListBoxItems.ClearSelected();
                    ListBoxItems.SetSelected(i, true);
                    ItemContextMenu.Show(loc);
                    return;
                }
            }
            ItemContextMenu.Items[0].Enabled = false;
            ItemContextMenu.Items[3].Enabled = false;
            ItemContextMenu.Items[4].Enabled = false;
            ItemContextMenu.Show(loc);
        }
Beispiel #2
0
        public MainForm(DataManager manager)
        {
            this.manager = manager;

            InitializeComponent();
            ResetLanguage();

            ReloadList();

            if (ListBoxItems.Items.Count > 0)
            {
                ListBoxItems.SetSelected(0, true);
            }
        }
Beispiel #3
0
        public void SetSelectByName(string name)
        {
            var i = ListBoxItems.FindStringExact(name);

            if (i < 0)
            {
                if (ListBoxItems.SelectedIndex < 0 && ListBoxItems.Items.Count > 0)
                {
                    ListBoxItems.SetSelected(0, true);
                }
            }
            else
            {
                if (!(ListBoxItems.SelectedIndex < 0))
                {
                    ListBoxItems.SetSelected(ListBoxItems.SelectedIndex, false);
                }
                ListBoxItems.SetSelected(i, true);
            }
        }