Changeset 7652 for branches/HeuristicLab.DataImporter
- Timestamp:
- 03/22/12 11:13:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Data/View/ColumnGroupView.cs
r7267 r7652 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel;25 24 using System.Drawing; 26 using System.Data;27 25 using System.Linq; 28 26 using System.Text; 29 27 using System.Windows.Forms; 28 using HeuristicLab.DataImporter.Data.Command; 30 29 using HeuristicLab.DataImporter.Data.Model; 31 using HeuristicLab.DataImporter.Data.Command;32 30 33 31 … … 58 56 this.dataGridView.AllowUserToOrderColumnsChanged += new EventHandler(dataGridView_AllowUserToOrderColumnsChanged); 59 57 this.dataGridView.KeyDown += new KeyEventHandler(dataGridView_KeyDown); 60 this.dataGridView.Scroll += new ScrollEventHandler(dataGridView_Scroll);61 this.dataGridView.Resize += new EventHandler(dataGridView_Resize);62 58 this.dataGridView.RowHeadersWidthChanged += new EventHandler(dataGridView_RowHeadersWidthChanged); 63 59 this.dataGridView.CellMouseEnter += new DataGridViewCellEventHandler(dataGridView_CellMouseEnter); … … 286 282 if (Math.Abs(dataGridView.RowCount - ColumnGroup.RowCount) > 10) 287 283 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); 294 286 295 287 if (rowAdded) { … … 300 292 this.dataGridView.CurrentCell.Selected = true; 301 293 } 302 UpdateRowHeaders();303 294 this.dataGridView.CellValuePushed += new DataGridViewCellValueEventHandler(dataGridView_CellValuePushed); 304 295 } 305 296 297 UpdateDataGridViewHeaderCells(); 306 298 this.dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); 307 299 this.dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders); … … 313 305 dataGridView.FirstDisplayedCell = dataGridView[firstVisibleColIndex, firstVisibleRowIndex]; 314 306 } 307 315 308 UpdateSortGlyph(); 316 309 this.txtColumnGroupName.Text = this.ColumnGroup.Name + " " + ColumnGroup.RowCount + " rows"; … … 318 311 this.dataGridView.Invalidate(); 319 312 UpdateStateInformation(); 313 } 314 315 private void UpdateDataGridViewHeaderCells() { 316 for (int i = 1; i <= columnGroup.RowCount; i++) 317 dataGridView.Rows[i].HeaderCell.Value = i.ToString(); 320 318 } 321 319 … … 462 460 else if (e.Control && e.KeyCode == Keys.C) 463 461 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();478 462 } 479 463 … … 548 532 549 533 #region DataGridView virtual mode event handler 550 551 534 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); 554 536 } 555 537 … … 597 579 } 598 580 } 599 600 581 #endregion 601 582
Note: See TracChangeset
for help on using the changeset viewer.