- Timestamp:
- 03/12/13 12:20:25 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
r7984 r9308 23 23 using System.ComponentModel; 24 24 using System.Drawing; 25 using System.Linq; 25 26 using System.Text; 26 27 using System.Windows.Forms; 27 using HeuristicLab.Common;28 28 using HeuristicLab.MainForm; 29 29 using HeuristicLab.MainForm.WindowsForms; … … 53 53 54 54 protected override void DeregisterContentEvents() { 55 Content. ItemChanged -= new EventHandler<EventArgs<int>>(Content_ItemChanged);55 Content.ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged); 56 56 Content.Reset -= new EventHandler(Content_Reset); 57 Content.ItemsChanged -= new EventHandler<ArrayValuesChangedEventArgs>(Content_ItemsChanged); 57 58 base.DeregisterContentEvents(); 58 59 } … … 60 61 protected override void RegisterContentEvents() { 61 62 base.RegisterContentEvents(); 62 Content.Item Changed += new EventHandler<EventArgs<int>>(Content_ItemChanged);63 Content.ItemsChanged += new EventHandler<ArrayValuesChangedEventArgs>(Content_ItemsChanged); 63 64 Content.Reset += new EventHandler(Content_Reset); 65 Content.ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged); 64 66 } 65 67 … … 94 96 dataGridView.Rows[i].Cells[0].Value = Content.GetValue(i); 95 97 } 98 96 99 dataGridView.Columns[0].Width = dataGridView.Columns[0].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); 97 100 } 101 UpdateRowHeaders(); 102 dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders); 98 103 dataGridView.Enabled = true; 99 104 } 100 105 101 private void Content_ItemChanged(object sender, EventArgs<int> e) { 106 protected virtual void UpdateRowHeaders() { 107 for (int i = 0; i < dataGridView.RowCount; i++) { 108 if (i < Content.ColumnNames.Count()) 109 dataGridView.Rows[i].HeaderCell.Value = Content.ColumnNames.ElementAt(i); 110 else 111 dataGridView.Rows[i].HeaderCell.Value = "Column " + (i + 1); 112 } 113 } 114 115 private void Content_ItemsChanged(object sender, ArrayValuesChangedEventArgs e) { 102 116 if (InvokeRequired) 103 Invoke(new EventHandler< EventArgs<int>>(Content_ItemChanged), sender, e);117 Invoke(new EventHandler<ArrayValuesChangedEventArgs>(Content_ItemsChanged), sender, e); 104 118 else { 105 dataGridView.Rows[e.Value].Cells[0].Value = Content.GetValue(e.Value); 106 Size size = dataGridView.Rows[e.Value].Cells[0].PreferredSize; 107 dataGridView.Columns[0].Width = Math.Max(dataGridView.Columns[0].Width, size.Width); 108 } 119 foreach (var index in e.Value) { 120 dataGridView.Rows[index].Cells[0].Value = Content.GetValue(index); 121 Size size = dataGridView.Rows[index].Cells[0].PreferredSize; 122 dataGridView.Columns[0].Width = Math.Max(dataGridView.Columns[0].Width, size.Width); 123 } 124 } 125 } 126 private void Content_ColumnNamesChanged(object sender, EventArgs e) { 127 if (InvokeRequired) 128 Invoke(new EventHandler(Content_ColumnNamesChanged), sender, e); 129 else 130 UpdateRowHeaders(); 109 131 } 110 132 private void Content_Reset(object sender, EventArgs e) {
Note: See TracChangeset
for help on using the changeset viewer.