internal void SelectSlot(int slot, bool select)
        {
            if (this.OwningGrid.RowGroupHeadersTable.Contains(slot))
            {
                return;
            }

            if (select)
            {
                if (!_selectedSlotsTable.Contains(slot))
                {
                    _selectedItemsCache.Add(this.OwningGrid.DataConnection.GetDataItem(this.OwningGrid.RowIndexFromSlot(slot)));
                }

                _selectedSlotsTable.AddValue(slot, true);
            }
            else
            {
                if (_selectedSlotsTable.Contains(slot))
                {
                    _selectedItemsCache.Remove(this.OwningGrid.DataConnection.GetDataItem(this.OwningGrid.RowIndexFromSlot(slot)));
                }

                _selectedSlotsTable.RemoveValue(slot);
            }
        }
        internal SelectionChangedEventArgs GetSelectionChangedEventArgs()
        {
            List <object> addedSelectedItems   = new List <object>();
            List <object> removedSelectedItems = new List <object>();

            // Compare the old selected indexes with the current selection to determine which items
            // have been added and removed since the last time this method was called
            foreach (int newSlot in _selectedSlotsTable.GetIndexes())
            {
                object newItem = this.OwningGrid.DataConnection.GetDataItem(this.OwningGrid.RowIndexFromSlot(newSlot));
                if (_oldSelectedSlotsTable.Contains(newSlot))
                {
                    _oldSelectedSlotsTable.RemoveValue(newSlot);
                    _oldSelectedItemsCache.Remove(newItem);
                }
                else
                {
                    addedSelectedItems.Add(newItem);
                }
            }

            foreach (object oldItem in _oldSelectedItemsCache)
            {
                removedSelectedItems.Add(oldItem);
            }

            // The current selection becomes the old selection
            _oldSelectedSlotsTable = _selectedSlotsTable.Copy();
            _oldSelectedItemsCache = new List <object>(_selectedItemsCache);

            return(new SelectionChangedEventArgs(removedSelectedItems, addedSelectedItems));
        }