Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/06/15 16:41:59 (9 years ago)
Author:
pfleck
Message:

#2486
Allows pasting of multiple values that extend the current data limits (rows and/or columns).
In case, additional rows and columns are added with the default value of the column's type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs

    r12676 r12983  
    142142
    143143
    144     //protected override void PasteValuesToDataGridView() {
    145     //  base.PasteValuesToDataGridView();
    146     //  dataGridView.Refresh();
    147     //}
     144    protected override void PasteValuesToDataGridView() {
     145      string[,] values = SplitClipboardString(Clipboard.GetText());
     146      int rowIndex = 0;
     147      int columnIndex = 0;
     148      if (dataGridView.CurrentCell != null) {
     149        rowIndex = dataGridView.CurrentCell.RowIndex;
     150        columnIndex = dataGridView.CurrentCell.ColumnIndex;
     151      }
     152      if (Content.Rows < values.GetLength(1) + rowIndex) Content.Rows = values.GetLength(1) + rowIndex;
     153      if (Content.Columns < values.GetLength(0) + columnIndex) Content.Columns = values.GetLength(0) + columnIndex;
     154
     155      ReplaceTransaction(() => {
     156        Content.PreProcessingData.InTransaction(() => {
     157          for (int row = 0; row < values.GetLength(1); row++) {
     158            for (int col = 0; col < values.GetLength(0); col++) {
     159              Content.SetValue(values[col, row], row + rowIndex, col + columnIndex);
     160            }
     161          }
     162        });
     163      });
     164
     165      ClearSorting();
     166      //UpdateData(); // rownames are created on DataGrid creation. Therefore, no update possible, yet.
     167    }
    148168
    149169    protected override void SetEnabledStateOfControls() {
Note: See TracChangeset for help on using the changeset viewer.