예제 #1
0
        public void ListBoxSelectedObjectCollection_IListAdd_Invoke_ThrowsNotSupportedException(object value)
        {
            using var owner = new ListBox();
            IList collection = new ListBox.SelectedObjectCollection(owner);

            Assert.Throws <NotSupportedException>(() => collection.Add(value));
        }
예제 #2
0
 private void ListBoxPartitions_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && listBoxPartitions.SelectedItems.Count > 0)
     {
         int mouseIndex = listBoxPartitions.IndexFromPoint(e.Location);
         if (mouseIndex > -1)
         {
             ListBox.SelectedObjectCollection x = new ListBox.SelectedObjectCollection(listBoxPartitions);
             if (Control.ModifierKeys == Keys.Shift)
             {
                 int i1 = Math.Min(listBoxPartitions.SelectedIndex, mouseIndex);
                 int i2 = Math.Max(listBoxPartitions.SelectedIndex, mouseIndex);
                 for (int i = i1; i <= i2; ++i)
                 {
                     x.Add(listBoxPartitions.Items[i]);
                 }
             }
             else
             {
                 x = listBoxPartitions.SelectedItems;
             }
             var dropResult = DoDragDrop(x, DragDropEffects.Move);
         }
     }
 }
예제 #3
0
        void SetSelection(List <string> inSelection)
        {
            ListBox.SelectedObjectCollection sel = new ListBox.SelectedObjectCollection(controlsLB);
            sel.Clear();

            foreach (string str in inSelection)
            {
                foreach (object obj in controlsLB.Items)
                {
                    if (obj.ToString() == str)
                    {
                        sel.Add(str);
                        break;
                    }
                }
            }
        }