System.Windows.Forms.ComboBox.ObjectCollection.Insert C# (CSharp) Method

Insert() public method

public Insert ( int index, object item ) : void
index int
item object
return void
			public void Insert (int index, object item)
			{
				if (index < 0 || index > Count)
					throw new ArgumentOutOfRangeException ("index");
				if (item == null)
					throw new ArgumentNullException ("item");
				
				owner.BeginUpdate ();
				
				if (owner.Sorted)
					AddItem (item, false);
				else
				{
					object_items.Insert (index, item);
					//UIA Framework event: Item added
					OnUIACollectionChangedEvent (new CollectionChangeEventArgs (CollectionChangeAction.Add, item));
				}
				
				owner.EndUpdate ();
				// Calls UpdatedItems
			}

Usage Example

Example #1
0
        public CreatTask(ScheduleForm form, ListView view)
        {
            InitializeComponent();
            scheduleform = form;
            listView = view;
            
            int i = 1;
            ComboBox.ObjectCollection Macs = new ComboBox.ObjectCollection(Computers);
            Macs.Insert(0, "");
            foreach(ListViewItem item in view.Items)
            {
                if (i != view.Items.Count)
                {
                    Macs.Insert(i, item.SubItems[1].Text);
                    i++;
                }
                
            }
            Computers.DataSource = Macs;

            
        }
All Usage Examples Of System.Windows.Forms.ComboBox.ObjectCollection::Insert