- Timestamp:
- 04/13/10 17:05:11 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Data.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.Designer.cs
r3316 r3328 92 92 this.dataGridView.Location = new System.Drawing.Point(0, 52); 93 93 this.dataGridView.Name = "dataGridView"; 94 this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;95 94 this.dataGridView.Size = new System.Drawing.Size(424, 352); 96 95 this.dataGridView.TabIndex = 4; -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r3324 r3328 63 63 Content.ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged); 64 64 Content.RowNamesChanged -= new EventHandler(Content_RowNamesChanged); 65 Content.ReadOnlyViewChanged -= new EventHandler(Content_ReadOnlyViewChanged); 65 66 base.DeregisterContentEvents(); 66 67 } 67 68 68 69 69 protected override void RegisterContentEvents() { … … 73 73 Content.ColumnNamesChanged += new EventHandler(Content_ColumnNamesChanged); 74 74 Content.RowNamesChanged += new EventHandler(Content_RowNamesChanged); 75 }76 75 Content.ReadOnlyViewChanged += new EventHandler(Content_ReadOnlyViewChanged); 76 } 77 77 78 78 79 79 protected override void OnContentChanged() { 80 80 base.OnContentChanged(); 81 sortedColumnIndizes.Clear();82 81 if (Content == null) { 83 82 Caption = "StringConvertibleMatrix View"; … … 92 91 } else { 93 92 Caption = "StringConvertibleMatrix (" + Content.GetType().Name + ")"; 93 UpdateReadOnlyControls(); 94 94 UpdateData(); 95 95 } … … 97 97 98 98 private void UpdateData() { 99 sortedColumnIndizes.Clear(); 100 Sort(); 99 101 rowsTextBox.Text = Content.Rows.ToString(); 100 102 rowsTextBox.Enabled = true; … … 102 104 columnsTextBox.Enabled = true; 103 105 virtualRowIndizes = Enumerable.Range(0, Content.Rows).ToArray(); 104 dataGridView.EndEdit(); 105 dataGridView.RowCount = 0; 106 dataGridView.ColumnCount = 0; 107 if ((Content.Rows > 0) && (Content.Columns > 0)) { 108 dataGridView.RowCount = Content.Rows; 109 dataGridView.ColumnCount = Content.Columns; 110 UpdateRowHeaders(); 111 UpdateColumnHeaders(); 112 } 113 dataGridView.ReadOnly = Content.ReadOnlyView; 106 dataGridView.RowCount = Content.Rows; 107 dataGridView.ColumnCount = Content.Columns; 108 UpdateRowHeaders(); 109 UpdateColumnHeaders(); 114 110 dataGridView.Enabled = true; 115 111 } … … 135 131 } 136 132 133 private void UpdateReadOnlyControls() { 134 dataGridView.ReadOnly = Content.ReadOnlyView; 135 rowsTextBox.ReadOnly = Content.ReadOnlyView; 136 columnsTextBox.ReadOnly = Content.ReadOnlyView; 137 } 138 137 139 private void Content_RowNamesChanged(object sender, EventArgs e) { 138 UpdateColumnHeaders(); 139 } 140 140 if (InvokeRequired) 141 Invoke(new EventHandler(Content_RowNamesChanged), sender, e); 142 else 143 UpdateRowHeaders(); 144 } 141 145 private void Content_ColumnNamesChanged(object sender, EventArgs e) { 142 UpdateRowHeaders(); 143 } 144 146 if (InvokeRequired) 147 Invoke(new EventHandler(Content_ColumnNamesChanged), sender, e); 148 else 149 UpdateColumnHeaders(); 150 } 145 151 private void Content_ItemChanged(object sender, EventArgs<int, int> e) { 146 152 if (InvokeRequired) 147 153 Invoke(new EventHandler<EventArgs<int, int>>(Content_ItemChanged), sender, e); 148 else {154 else 149 155 dataGridView.InvalidateCell(e.Value, e.Value2); 150 }151 156 } 152 157 private void Content_Reset(object sender, EventArgs e) { … … 155 160 else 156 161 UpdateData(); 162 } 163 164 private void Content_ReadOnlyViewChanged(object sender, EventArgs e) { 165 if (InvokeRequired) 166 Invoke(new EventHandler(Content_ReadOnlyViewChanged), sender, e); 167 else 168 UpdateReadOnlyControls(); 157 169 } 158 170 … … 167 179 } 168 180 private void rowsTextBox_Validated(object sender, EventArgs e) { 169 Content.Rows = int.Parse(rowsTextBox.Text); 181 int textBoxValue = int.Parse(rowsTextBox.Text); 182 if (textBoxValue != Content.Rows) 183 Content.Rows = textBoxValue; 170 184 errorProvider.SetError(rowsTextBox, string.Empty); 171 185 } … … 187 201 } 188 202 private void columnsTextBox_Validated(object sender, EventArgs e) { 189 Content.Columns = int.Parse(columnsTextBox.Text); 203 int textBoxValue = int.Parse(columnsTextBox.Text); 204 if (textBoxValue != Content.Columns) 205 Content.Columns = textBoxValue; 190 206 errorProvider.SetError(columnsTextBox, string.Empty); 191 207 } … … 202 218 #region DataGridView Events 203 219 private void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 204 string errorMessage; 205 if (!Content.Validate(e.FormattedValue.ToString(), out errorMessage)) { 206 e.Cancel = true; 207 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 220 if (!dataGridView.ReadOnly) { 221 string errorMessage; 222 if (!Content.Validate(e.FormattedValue.ToString(), out errorMessage)) { 223 e.Cancel = true; 224 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 225 } 208 226 } 209 227 } 210 228 private void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 211 string value = e.Value.ToString(); 212 int rowIndex = virtualRowIndizes[e.RowIndex]; 213 e.ParsingApplied = Content.SetValue(value, rowIndex, e.ColumnIndex); 214 if (e.ParsingApplied) e.Value = Content.GetValue(rowIndex, e.ColumnIndex); 229 if (!dataGridView.ReadOnly) { 230 string value = e.Value.ToString(); 231 int rowIndex = virtualRowIndizes[e.RowIndex]; 232 e.ParsingApplied = Content.SetValue(value, rowIndex, e.ColumnIndex); 233 if (e.ParsingApplied) e.Value = Content.GetValue(rowIndex, e.ColumnIndex); 234 } 215 235 } 216 236 private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { … … 262 282 263 283 private void Sort() { 264 int[] newSortedIndex = Enumerable.Range(0, Content.Rows - 1).ToArray();284 int[] newSortedIndex = Enumerable.Range(0, Content.Rows).ToArray(); 265 285 if (sortedColumnIndizes.Count != 0) { 266 286 rowComparer.sortedIndizes = sortedColumnIndizes; … … 269 289 } 270 290 virtualRowIndizes = newSortedIndex; 291 UpdateSortGlyph(); 271 292 dataGridView.Invalidate(); 293 } 294 295 private void UpdateSortGlyph() { 272 296 foreach (DataGridViewColumn col in this.dataGridView.Columns) 273 297 col.HeaderCell.SortGlyphDirection = SortOrder.None;
Note: See TracChangeset
for help on using the changeset viewer.