Example #1
0
 internal virtual void RemoveInternal(DataGridViewRow dataGridViewRow)
 {
     DataGridView.OnRowsPreRemovedInternal(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
     list.Remove(dataGridViewRow);
     ReIndex();
     OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, dataGridViewRow));
     DataGridView.OnRowsPostRemovedInternal(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
 }
Example #2
0
        public virtual void Remove(DataGridViewRow dataGridViewRow)
        {
            if (dataGridViewRow.IsNewRow)
            {
                throw new InvalidOperationException("Cannot delete the new row");
            }

            DataGridView.OnRowsPreRemovedInternal(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
            list.Remove(dataGridViewRow);
            ReIndex();
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, dataGridViewRow));
            DataGridView.OnRowsPostRemovedInternal(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
        }
Example #3
0
        public virtual void Clear()
        {
            int total = list.Count;

            DataGridView.OnRowsPreRemovedInternal(new DataGridViewRowsRemovedEventArgs(0, total));

            for (int i = 0; i < total; i++)
            {
                DataGridViewRow row = (DataGridViewRow)list[0];

                // We can exit because the NewRow is always last
                if (row.IsNewRow)
                {
                    break;
                }

                list.Remove(row);
                ReIndex();
            }

            DataGridView.OnRowsPostRemovedInternal(new DataGridViewRowsRemovedEventArgs(0, total));
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null));
        }