Exemplo n.º 1
0
        private void CreateBoxes()
        {
            //Create output boxes
            if (_NrOfOutputLists > _outputboxes.Count)
            {
                //_outputboxes.Reverse();
                for (int i = _outputboxes.Count; i < _NrOfOutputLists; i++)
                {
                    extendedListbox <Ploeg> _out = new extendedListbox <Ploeg>(new ExtBindingList <Ploeg>())
                    {
                        Dock      = DockStyle.Top,
                        Name      = _BindingSourceList.Name + "_Reeks_" + (i + 1).ToString(),
                        AllowDrop = true,
                    };
                    _outputboxes.Add(_out);
                    _out.ItemAdded += ItemAdded;
                }
            }
            //removing a box - set back the items to the input box and list
            else if (_NrOfOutputLists < _outputboxes.Count)
            {
                //_outputboxes.Reverse();
                int AantalTeVerwijderen = _outputboxes.Count - _NrOfOutputLists;

                for (int i = 0; i < AantalTeVerwijderen; i++)
                {
                    extendedListbox <Ploeg> removebox = _outputboxes.Last();
                    foreach (Ploeg item in removebox.Items)
                    {
                        _inputlist.Add(item);
                    }
                    splitContainer1.Panel2.Controls.Remove(removebox);
                    splitContainer1.Panel2.Refresh();
                    _outputboxes.Remove(removebox);
                    removebox.Dispose();
                    removebox = null;
                }
            }

            //remove all box controls and labels
            splitContainer1.Panel2.Controls.Clear();
            //fill up the boxes
            _outputboxes.Reverse();
            foreach (extendedListbox <Ploeg> box in _outputboxes)
            {
                //add items in outputlist and clean input list
                foreach (Ploeg pl in _inputlist)
                {
                    if (pl.Reeksnaam == box.Name)
                    {
                        box.Items.Add(pl);
                    }
                }
                //clean the input
                foreach (Ploeg pl in box.Items)
                {
                    _inputlist.Remove(pl);
                }
                splitContainer1.Panel2.Controls.Add(box);
                splitContainer1.Panel2.Controls.Add(new Label()
                {
                    Text = box.Name, Dock = DockStyle.Top
                });
            }



            splitContainer1.Panel2.Refresh();

            ///input as last step becuase depending on items already in an output list, the input list gets filtered
            splitContainer1.Panel1.Controls.Clear();
            _inputbox = new extendedListbox <Ploeg>(_inputlist);
            //naam van de reeks
            _inputbox.Name       = _BindingSourceList.Name;
            _inputbox.ItemAdded += ItemAdded;
            _inputbox.AutoSize   = true;
            _inputbox.Dock       = DockStyle.Top;
            Label _inputlabel = new Label()
            {
                Text = _inputbox.Name, Dock = DockStyle.Top
            };

            splitContainer1.Panel1.Controls.Add(_inputbox);
            splitContainer1.Panel1.Controls.Add(_inputlabel);



            _outputboxes.Reverse();
        }