Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/22/12 11:13:17 (13 years ago)
Author:
mkommend
Message:

#1804: improved responsiveness of DataImporter during scroll operations.

File:
1 edited

Legend:

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

    r7267 r7652  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.ComponentModel;
    2524using System.Drawing;
    26 using System.Data;
    2725using System.Linq;
    2826using System.Text;
    2927using System.Windows.Forms;
     28using HeuristicLab.DataImporter.Data.Command;
    3029using HeuristicLab.DataImporter.Data.Model;
    31 using HeuristicLab.DataImporter.Data.Command;
    3230
    3331
     
    5856      this.dataGridView.AllowUserToOrderColumnsChanged += new EventHandler(dataGridView_AllowUserToOrderColumnsChanged);
    5957      this.dataGridView.KeyDown += new KeyEventHandler(dataGridView_KeyDown);
    60       this.dataGridView.Scroll += new ScrollEventHandler(dataGridView_Scroll);
    61       this.dataGridView.Resize += new EventHandler(dataGridView_Resize);
    6258      this.dataGridView.RowHeadersWidthChanged += new EventHandler(dataGridView_RowHeadersWidthChanged);
    6359      this.dataGridView.CellMouseEnter += new DataGridViewCellEventHandler(dataGridView_CellMouseEnter);
     
    286282        if (Math.Abs(dataGridView.RowCount - ColumnGroup.RowCount) > 10)
    287283          dataGridView.Rows.Clear();
    288         bool rowAdded = false;
    289         //new row added - dataGridView has always one row more because of the last empty row for inserting new rows
    290         if (dataGridView.RowCount == ColumnGroup.RowCount && dataGridView.RowCount != 0)
    291           rowAdded = true;
    292 
    293         dataGridView.RowCount = ColumnGroup.RowCount + (ColumnGroup.Columns.Count() == 0 ? 0 : 1);
     284        bool rowAdded = dataGridView.RowCount == ColumnGroup.RowCount && dataGridView.RowCount != 0;
     285        dataGridView.RowCount = ColumnGroup.RowCount + (!ColumnGroup.Columns.Any() ? 0 : 1);
    294286
    295287        if (rowAdded) {
     
    300292          this.dataGridView.CurrentCell.Selected = true;
    301293        }
    302         UpdateRowHeaders();
    303294        this.dataGridView.CellValuePushed += new DataGridViewCellValueEventHandler(dataGridView_CellValuePushed);
    304295      }
    305296
     297      UpdateDataGridViewHeaderCells();
    306298      this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
    307299      this.dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
     
    313305        dataGridView.FirstDisplayedCell = dataGridView[firstVisibleColIndex, firstVisibleRowIndex];
    314306      }
     307
    315308      UpdateSortGlyph();
    316309      this.txtColumnGroupName.Text = this.ColumnGroup.Name + "  " + ColumnGroup.RowCount + " rows";
     
    318311      this.dataGridView.Invalidate();
    319312      UpdateStateInformation();
     313    }
     314
     315    private void UpdateDataGridViewHeaderCells() {
     316      for (int i = 1; i <= columnGroup.RowCount; i++)
     317        dataGridView.Rows[i].HeaderCell.Value = i.ToString();
    320318    }
    321319
     
    462460      else if (e.Control && e.KeyCode == Keys.C)
    463461        CopyClipboardContent();
    464     }
    465 
    466     private void dataGridView_Scroll(object sender, ScrollEventArgs e) {
    467       UpdateRowHeaders();
    468     }
    469 
    470     private void dataGridView_Resize(object sender, EventArgs e) {
    471       UpdateRowHeaders();
    472     }
    473 
    474     private void UpdateRowHeaders() {
    475       for (int i = dataGridView.FirstDisplayedScrollingRowIndex; i < dataGridView.FirstDisplayedScrollingRowIndex + dataGridView.DisplayedRowCount(true); i++)
    476         dataGridView.Rows[i].HeaderCell.Value = i.ToString();
    477       dataGridView.Invalidate();
    478462    }
    479463
     
    548532
    549533    #region DataGridView virtual mode event handler
    550 
    551534    private void dataGridView_CellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e) {
    552       if (e.ColumnIndex < this.ColumnGroup.Columns.Count())
    553         e.Value = ColumnGroup.Columns.ElementAt(e.ColumnIndex).GetValue(e.RowIndex);
     535      e.Value = ColumnGroup.Columns.ElementAt(e.ColumnIndex).GetValue(e.RowIndex);
    554536    }
    555537
     
    597579      }
    598580    }
    599 
    600581    #endregion
    601582
Note: See TracChangeset for help on using the changeset viewer.