Changeset 16692 for branches/2521_ProblemRefactoring/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
- Timestamp:
- 03/18/19 17:24:30 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Data.Views
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Data.Views/3.3
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r12983 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 131 131 virtualRowIndices = Enumerable.Range(0, Content.Rows).ToArray(); 132 132 133 if (Content.Columns == 0 && dataGridView.ColumnCount != Content.Columns && !Content.ReadOnly) 134 Content.Columns = dataGridView.ColumnCount; 135 else { 136 DataGridViewColumn[] columns = new DataGridViewColumn[Content.Columns]; 137 for (int i = 0; i < columns.Length; ++i) { 138 var column = new DataGridViewTextBoxColumn(); 139 column.FillWeight = 1; 140 columns[i] = column; 141 } 142 dataGridView.Columns.Clear(); 133 134 dataGridView.RowCount = 0; 135 136 DataGridViewColumn[] columns = new DataGridViewColumn[Content.Columns]; 137 for (int i = 0; i < columns.Length; ++i) { 138 var column = new DataGridViewTextBoxColumn(); 139 column.SortMode = DataGridViewColumnSortMode.Programmatic; 140 column.FillWeight = 1; 141 columns[i] = column; 142 } 143 dataGridView.Columns.Clear(); 144 145 if (Content.Columns != 0) { 143 146 dataGridView.Columns.AddRange(columns); 144 }145 146 //DataGridViews with rows but no columns are not allowed !147 if (Content.Rows == 0 && dataGridView.RowCount != Content.Rows && !Content.ReadOnly)148 Content.Rows = dataGridView.RowCount;149 else150 147 dataGridView.RowCount = Content.Rows; 151 148 } 152 149 153 150 ClearSorting(); … … 160 157 } 161 158 162 p rotectedvirtual void UpdateColumnHeaders() {159 public virtual void UpdateColumnHeaders() { 163 160 HashSet<string> invisibleColumnNames = new HashSet<string>(dataGridView.Columns.OfType<DataGridViewColumn>() 164 161 .Where(c => !c.Visible && !string.IsNullOrEmpty(c.HeaderText)).Select(c => c.HeaderText)); … … 172 169 } 173 170 } 174 p rotectedvirtual void UpdateRowHeaders() {171 public virtual void UpdateRowHeaders() { 175 172 int index = dataGridView.FirstDisplayedScrollingRowIndex; 176 173 if (index == -1) index = 0; … … 262 259 263 260 #region DataGridView Events 261 264 262 protected virtual void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 265 if (!dataGridView.ReadOnly) { 266 string errorMessage; 267 if (Content != null && !Content.Validate(e.FormattedValue.ToString(), out errorMessage)) { 268 e.Cancel = true; 269 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 270 } 271 } 272 } 263 if (dataGridView.ReadOnly) return; 264 if (Content == null) return; 265 if (Content.Rows <= e.RowIndex || Content.Columns <= e.ColumnIndex) return; 266 267 string errorMessage; 268 if (!Content.Validate(e.FormattedValue.ToString(), out errorMessage)) { 269 e.Cancel = true; 270 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 271 } 272 } 273 273 274 protected virtual void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 274 275 if (!dataGridView.ReadOnly) { … … 440 441 } else 441 442 if (newSortOrder != SortOrder.None) 442 443 sortedColumnIndices.Add(new KeyValuePair<int, SortOrder>(columnIndex, newSortOrder)); 443 444 Sort(); 444 445 }
Note: See TracChangeset
for help on using the changeset viewer.