Exemple #1
0
        /// <summary>
        /// Reject every changes made since last AcceptChanges()
        /// </summary>
        public void RejectChanges()
        {
            DmRow[] oldRows = new DmRow[Rows.Count];
            Rows.CopyTo(oldRows, 0);

            for (int i = 0; i < oldRows.Length; i++)
            {
                oldRows[i].Rollback();
            }
        }
Exemple #2
0
        public override void Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction)
        {
            var comp = new OutlookGridRowComparer(dataGridViewColumn.Index, direction);
            var rows = new DataGridViewRow[this.Rows.Count];

            Rows.CopyTo(rows, 0);
            Rows.Clear();
            base.Sort(dataGridViewColumn, direction);
            Rows.AddRange(rows);
            if (dataSource == null)
            {
                dataSource = new DataSourceManager(this, null);
            }
            dataSource.Sort(comp);
            FillGrid(groupTemplate);
        }
Exemple #3
0
        private void Delete()
        {
            var lowIndex = int.MaxValue;
            var count    = 0;

            foreach (DataGridViewRow row in SelectedRows)
            {
                if (row.Index < lowIndex)
                {
                    lowIndex = row.Index;
                }

                count++;
            }

            // Copy all rows
            var allRows = new DataGridViewRow[RowCount];

            Rows.CopyTo(allRows, 0);

            // Copy all rows that are not deleted
            // The "- 1" is because the last, empty row is counted, and we don't want it.
            var keptRows = new DataGridViewRow[RowCount - count - 1];

            Array.Copy(allRows, 0, keptRows, 0, lowIndex);
            Array.Copy(allRows, lowIndex + count, keptRows, lowIndex, keptRows.Length - lowIndex);

            // Find the currently "top" row
            var scrollIndex = FirstDisplayedScrollingRowIndex;

            // Clear and refill
            Rows.Clear();
            Rows.AddRange(keptRows);

            // Scroll back
            if (scrollIndex >= RowCount)
            {
                scrollIndex = RowCount - 1;
            }

            FirstDisplayedScrollingRowIndex = scrollIndex;

            // Renumber the rows
            NumberRows(0);

            PendingChanges = true;
        }
Exemple #4
0
 public void CopyTo(TEntity[] array, int index)
 {
     Rows.CopyTo(array, index);
 }
 public void CopyTo(Array array, int arrayIndex)
 {
     Rows.CopyTo(array, arrayIndex);
 }