Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3936


Ignore:
Timestamp:
06/21/10 16:46:44 (14 years ago)
Author:
mkommend
Message:

improved StringConvertibleMatrixView (ticket #968)

Location:
trunk/sources/HeuristicLab.Data.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.Designer.cs

    r3643 r3936  
    8888                  | System.Windows.Forms.AnchorStyles.Left)
    8989                  | System.Windows.Forms.AnchorStyles.Right)));
    90       this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
    9190      this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
    9291      this.dataGridView.Location = new System.Drawing.Point(0, 52);
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs

    r3904 r3936  
    8484        dataGridView.Columns.Clear();
    8585        virtualRowIndizes = new int[0];
    86       } else 
     86      } else
    8787        UpdateData();
    8888    }
     
    9999
    100100    private void UpdateData() {
    101       sortedColumnIndizes.Clear();
     101      ClearSorting();
    102102      rowsTextBox.Text = Content.Rows.ToString();
    103103      rowsTextBox.Enabled = true;
    104104      columnsTextBox.Text = Content.Columns.ToString();
    105105      columnsTextBox.Enabled = true;
    106       virtualRowIndizes = Enumerable.Range(0, Content.Rows).ToArray();
    107106      //DataGridViews with Rows but no columns are not allowed !
    108107      if (Content.Rows == 0 && dataGridView.RowCount != Content.Rows && !Content.ReadOnly)
     
    115114        dataGridView.ColumnCount = Content.Columns;
    116115
    117       Sort();
    118116      UpdateRowHeaders();
    119117      UpdateColumnHeaders();
    120       dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader);
    121       dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
    122118      dataGridView.Enabled = true;
    123119    }
    124120
    125121    private void UpdateColumnHeaders() {
    126       for (int i = 0; i < Content.Columns; i++) {
     122      int firstDisplayedColumnIndex = this.dataGridView.FirstDisplayedScrollingColumnIndex;
     123      if (firstDisplayedColumnIndex == -1)
     124        firstDisplayedColumnIndex = 0;
     125      int lastDisplayedColumnIndex = firstDisplayedColumnIndex + dataGridView.DisplayedColumnCount(true);
     126      for (int i = firstDisplayedColumnIndex; i < lastDisplayedColumnIndex; i++) {
    127127        if (Content.ColumnNames.Count() != 0)
    128128          dataGridView.Columns[i].HeaderText = Content.ColumnNames.ElementAt(i);
     
    130130          dataGridView.Columns[i].HeaderText = "Column " + (i + 1);
    131131      }
    132       dataGridView.Invalidate();
     132      dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader);
    133133    }
    134134
    135135    private void UpdateRowHeaders() {
    136       for (int i = 0; i < dataGridView.RowCount; i++) {
     136      int firstDisplayedRowIndex = dataGridView.FirstDisplayedScrollingRowIndex;
     137      if(firstDisplayedRowIndex == -1)
     138        firstDisplayedRowIndex = 0;
     139      int lastDisplaydRowIndex = firstDisplayedRowIndex + dataGridView.DisplayedRowCount(true);
     140      for (int i = firstDisplayedRowIndex; i < lastDisplaydRowIndex; i++) {
    137141        if (Content.RowNames.Count() != 0)
    138142          dataGridView.Rows[i].HeaderCell.Value = Content.RowNames.ElementAt(virtualRowIndizes[i]);
     
    140144          dataGridView.Rows[i].HeaderCell.Value = "Row " + (i + 1);
    141145      }
    142       dataGridView.Invalidate();
     146      dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
    143147    }
    144148
     
    244248    private void dataGridView_Scroll(object sender, ScrollEventArgs e) {
    245249      UpdateRowHeaders();
     250      UpdateColumnHeaders();
    246251    }
    247252    private void dataGridView_Resize(object sender, EventArgs e) {
    248253      UpdateRowHeaders();
     254      UpdateColumnHeaders();
    249255    }
    250256
Note: See TracChangeset for help on using the changeset viewer.