Changeset 15074
- Timestamp:
- 06/27/17 17:39:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r14443 r15074 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.SortMode = DataGridViewColumnSortMode.Programmatic; 140 column.FillWeight = 1; 141 columns[i] = column; 142 } 143 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) { 144 146 dataGridView.Columns.AddRange(columns); 145 }146 147 //DataGridViews with rows but no columns are not allowed !148 if (Content.Rows == 0 && dataGridView.RowCount != Content.Rows && !Content.ReadOnly)149 Content.Rows = dataGridView.RowCount;150 else151 147 dataGridView.RowCount = Content.Rows; 152 148 } 153 149 154 150 ClearSorting(); … … 263 259 264 260 #region DataGridView Events 261 265 262 protected virtual void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 266 if (!dataGridView.ReadOnly) { 267 string errorMessage; 268 if (Content != null && !Content.Validate(e.FormattedValue.ToString(), out errorMessage)) { 269 e.Cancel = true; 270 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 271 } 272 } 273 } 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 274 274 protected virtual void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 275 275 if (!dataGridView.ReadOnly) { … … 441 441 } else 442 442 if (newSortOrder != SortOrder.None) 443 443 sortedColumnIndices.Add(new KeyValuePair<int, SortOrder>(columnIndex, newSortOrder)); 444 444 Sort(); 445 445 }
Note: See TracChangeset
for help on using the changeset viewer.