Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7731


Ignore:
Timestamp:
04/16/12 16:38:05 (12 years ago)
Author:
sforsten
Message:

#1818: The previous solution didn't work out.
Similar to the StringConvertibleMatrixView the ColumnGroupView now only updates the row headers which are displayed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Data/View/ColumnGroupView.cs

    r7730 r7731  
    5858      this.dataGridView.RowHeadersWidthChanged += new EventHandler(dataGridView_RowHeadersWidthChanged);
    5959      this.dataGridView.CellMouseEnter += new DataGridViewCellEventHandler(dataGridView_CellMouseEnter);
    60       this.dataGridView.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView_CellFormatting);
     60      this.dataGridView.Scroll += new ScrollEventHandler(dataGridView_Scroll);
     61      this.dataGridView.Resize += new EventHandler(dataGridView_Resize);
    6162
    6263      //delegates for virtual mode
     
    296297      }
    297298
     299      UpdateDataGridViewHeaderCells();
    298300      this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
    299301      this.dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
     
    311313      this.dataGridView.Invalidate();
    312314      UpdateStateInformation();
     315    }
     316
     317    private void UpdateDataGridViewHeaderCells() {
     318      int index = dataGridView.FirstDisplayedScrollingRowIndex;
     319      if (index == -1) index = 0;
     320      int updatedRows = 0;
     321      int count = dataGridView.DisplayedRowCount(true);
     322
     323      while (updatedRows < count) {
     324        dataGridView.Rows[index].HeaderCell.Value = (index + 1).ToString();
     325        if (dataGridView.Rows[index].Visible)
     326          updatedRows++;
     327        index++;
     328      }
    313329    }
    314330
     
    469485    }
    470486
    471     private void dataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) {
    472       this.dataGridView.Rows[e.RowIndex].HeaderCell.Value = e.RowIndex.ToString();
     487    private void dataGridView_Resize(object sender, EventArgs e) {
     488      UpdateDataGridViewHeaderCells();
     489    }
     490
     491    private void dataGridView_Scroll(object sender, ScrollEventArgs e) {
     492      if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
     493        UpdateDataGridViewHeaderCells();
    473494    }
    474495
Note: See TracChangeset for help on using the changeset viewer.