internal virtual void RemoveInternal(DataGridViewRow dataGridViewRow)
 {
     DataGridView.OnRowsPreRemovedInternal(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
     dataGridViewRow.SetDataGridView(null);
     list.Remove(dataGridViewRow);
     ReIndex();
     OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, dataGridViewRow));
     DataGridView.OnRowsPostRemovedInternal(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
 }
Ejemplo n.º 2
0
        private int AddCore(DataGridViewRow dataGridViewRow, bool sharable)
        {
            if (dataGridView.Columns.Count == 0)
            {
                throw new InvalidOperationException("DataGridView has no columns.");
            }

            int result;

            dataGridViewRow.SetDataGridView(dataGridView);

            //
            // Add the row just before the editing row (if there is an editing row).
            //
            int editing_index = -1;

            if (DataGridView != null && DataGridView.EditingRow != null && DataGridView.EditingRow != dataGridViewRow)
            {
                editing_index = list.Count - 1;                 // always the last row
                DataGridView.EditingRow.SetIndex(list.Count);
            }

            if (editing_index >= 0)
            {
                list.Insert(editing_index, dataGridViewRow);
                result = editing_index;
            }
            else
            {
                result = list.Add(dataGridViewRow);
            }

            if (sharable && CanBeShared(dataGridViewRow))
            {
                dataGridViewRow.SetIndex(-1);
            }
            else
            {
                dataGridViewRow.SetIndex(result);
            }

            CompleteRowCells(dataGridViewRow);
            for (int i = 0; i < dataGridViewRow.Cells.Count; i++)
            {
                dataGridViewRow.Cells [i].SetOwningColumn(dataGridView.Columns [i]);
            }

            if (raiseEvent)
            {
                OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewRow));
                DataGridView.OnRowsAddedInternal(new DataGridViewRowsAddedEventArgs(result, 1));
            }

            return(result);
        }
Ejemplo n.º 3
0
 // FIXME: Do *not* allow insertation *after* the editing row!
 public virtual void Insert(int rowIndex, DataGridViewRow dataGridViewRow)
 {
     dataGridViewRow.SetIndex(rowIndex);
     dataGridViewRow.SetDataGridView(dataGridView);
     CompleteRowCells(dataGridViewRow);
     list.Insert(rowIndex, dataGridViewRow);
     ReIndex();
     OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewRow));
     if (raiseEvent)
     {
         DataGridView.OnRowsAddedInternal(new DataGridViewRowsAddedEventArgs(rowIndex, 1));
     }
 }
        public virtual void Remove(DataGridViewRow dataGridViewRow)
        {
            if (dataGridViewRow.IsNewRow)
            {
                throw new InvalidOperationException("Cannot delete the new row");
            }

            DataGridView.OnRowsPreRemovedInternal(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
            dataGridViewRow.SetDataGridView(null);
            list.Remove(dataGridViewRow);
            ReIndex();
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, dataGridViewRow));
            DataGridView.OnRowsPostRemovedInternal(new DataGridViewRowsRemovedEventArgs(dataGridViewRow.Index, 1));
        }
Ejemplo n.º 5
0
        public override object Clone()
        {
            DataGridViewRow row = (DataGridViewRow)MemberwiseClone();

            row.HeaderCell = (DataGridViewRowHeaderCell)HeaderCell.Clone();
            row.SetIndex(-1);

            row.cells = new DataGridViewCellCollection(row);

            foreach (DataGridViewCell cell in cells)
            {
                row.cells.Add(cell.Clone() as DataGridViewCell);
            }

            row.SetDataGridView(null);

            return(row);
        }
Ejemplo n.º 6
0
        public override object Clone()
        {
            DataGridViewRow row = (DataGridViewRow)MemberwiseClone();

            row.DefaultCellStyle = (DataGridViewCellStyle)DefaultCellStyle.Clone();
            row.HeaderCell       = (DataGridViewRowHeaderCell)HeaderCell.Clone();
            row.SetIndex(-1);

            row.cells = null;

            foreach (DataGridViewCell cell in Cells)
            {
                row.Cells.Add(cell.Clone() as DataGridViewCell);
            }

            row.SetDataGridView(null);

            return(row);
        }
        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];
                row.SetIndex(0);

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

                row.SetDataGridView(null);
                list.Remove(row);
            }

            DataGridView.OnRowsPostRemovedInternal(new DataGridViewRowsRemovedEventArgs(0, total));
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null));
        }
Ejemplo n.º 8
0
		internal virtual void RemoveInternal (DataGridViewRow dataGridViewRow)
		{
			DataGridView.OnRowsPreRemovedInternal (new DataGridViewRowsRemovedEventArgs (dataGridViewRow.Index, 1));
			dataGridViewRow.SetDataGridView (null);
			list.Remove (dataGridViewRow);
			ReIndex ();
			OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, dataGridViewRow));
			DataGridView.OnRowsPostRemovedInternal (new DataGridViewRowsRemovedEventArgs (dataGridViewRow.Index, 1));
		}
Ejemplo n.º 9
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));
			dataGridViewRow.SetDataGridView (null);
			list.Remove (dataGridViewRow);
			ReIndex ();
			OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, dataGridViewRow));
			DataGridView.OnRowsPostRemovedInternal (new DataGridViewRowsRemovedEventArgs (dataGridViewRow.Index, 1));
		}
Ejemplo n.º 10
0
		// FIXME: Do *not* allow insertation *after* the editing row!
		public virtual void Insert (int rowIndex, DataGridViewRow dataGridViewRow)
		{
			dataGridViewRow.SetIndex (rowIndex);
			dataGridViewRow.SetDataGridView (dataGridView);
			CompleteRowCells (dataGridViewRow);
			list.Insert (rowIndex, dataGridViewRow);
			ReIndex ();
			OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, dataGridViewRow));
			if (raiseEvent)
				DataGridView.OnRowsAddedInternal (new DataGridViewRowsAddedEventArgs (rowIndex, 1));
		}
Ejemplo n.º 11
0
		private int AddCore (DataGridViewRow dataGridViewRow, bool sharable)
		{
			if (dataGridView.Columns.Count == 0)
				throw new InvalidOperationException ("DataGridView has no columns.");
			
			int result;
			
			dataGridViewRow.SetDataGridView (dataGridView);

			// 
			// Add the row just before the editing row (if there is an editing row).
			// 
			int editing_index = -1;
			if (DataGridView != null && DataGridView.EditingRow != null && DataGridView.EditingRow != dataGridViewRow) {
				editing_index = list.Count - 1; // always the last row
				DataGridView.EditingRow.SetIndex (list.Count);
			}
			
			if (editing_index >= 0) {
				list.Insert (editing_index, dataGridViewRow);
				result = editing_index;
			} else {
				result = list.Add (dataGridViewRow);
			}
			
			if (sharable && CanBeShared (dataGridViewRow)) {
				dataGridViewRow.SetIndex (-1);
			} else {
				dataGridViewRow.SetIndex (result);
			}

			CompleteRowCells (dataGridViewRow);
			for (int i = 0; i < dataGridViewRow.Cells.Count; i++) {
				dataGridViewRow.Cells [i].SetOwningColumn (dataGridView.Columns [i]);
			}

			if (raiseEvent) {
				OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, dataGridViewRow));
				DataGridView.OnRowsAddedInternal (new DataGridViewRowsAddedEventArgs (result, 1));
			}

			return result;
		}