Changeset 4707


Ignore:
Timestamp:
11/02/10 13:38:43 (9 years ago)
Author:
mkommend
Message:

Fixed StringConvertibleMatrix and RunCollectionTabularView to handle filter columns correctly (ticket #1251).

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs

    r4652 r4707  
    116116      columnsTextBox.Text = Content.Columns.ToString();
    117117      columnsTextBox.Enabled = true;
     118
    118119      //DataGridViews with rows but no columns are not allowed !
    119120      if (Content.Rows == 0 && dataGridView.RowCount != Content.Rows && !Content.ReadOnly)
     
    129130      UpdateColumnHeaders();
    130131      UpdateRowHeaders();
     132
    131133      dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader);
    132134      dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
     
    135137
    136138    protected void UpdateColumnHeaders() {
     139      HashSet<string> visibleColumnNames = new HashSet<string>(dataGridView.Columns.OfType<DataGridViewColumn>()
     140          .Where(c => c.Visible && !string.IsNullOrEmpty(c.HeaderText)).Select(c => c.HeaderText));
     141
    137142      for (int i = 0; i < dataGridView.ColumnCount; i++) {
    138         if (Content.ColumnNames.Count() != 0)
     143        if (i < Content.ColumnNames.Count())
    139144          dataGridView.Columns[i].HeaderText = Content.ColumnNames.ElementAt(i);
    140145        else
    141146          dataGridView.Columns[i].HeaderText = "Column " + (i + 1);
    142147      }
     148
     149      foreach (DataGridViewColumn column in dataGridView.Columns)
     150        column.Visible = visibleColumnNames.Contains(column.HeaderText) || visibleColumnNames.Count == 0;
    143151    }
    144152    protected void UpdateRowHeaders() {
     
    149157
    150158      while (updatedRows < count) {
    151         if (Content.RowNames.Count() != 0)
     159        if (virtualRowIndizes[index] < Content.RowNames.Count())
    152160          dataGridView.Rows[index].HeaderCell.Value = Content.RowNames.ElementAt(virtualRowIndizes[index]);
    153161        else
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r4518 r4707  
    8888          columnNamesChanged |= AddResult(result.Key, result.Value);
    8989      }
    90       if (columnNamesChanged) {
    91         columnNameCache = null;
    92         OnColumnNamesChanged();
    93       }
     90      if (columnNamesChanged) columnNameCache = null;
    9491      rowNamesCache = null;
    9592      base.OnItemsAdded(items);
     93      OnReset();
    9694      OnRowNamesChanged();
    97       OnReset();
     95      if (columnNamesChanged) OnColumnNamesChanged();
    9896      UpdateFiltering(false);
    9997    }
     
    106104          columnNamesChanged |= RemoveResultName(resultName);
    107105      }
    108       if (columnNamesChanged) {
    109         columnNameCache = null;
    110         OnColumnNamesChanged();
    111       }
     106      if (columnNamesChanged) columnNameCache = null;
    112107      rowNamesCache = null;
    113108      base.OnItemsRemoved(items);
     109      OnReset();
    114110      OnRowNamesChanged();
    115       OnReset();
     111      if (columnNamesChanged) OnColumnNamesChanged();
    116112    }
    117113
Note: See TracChangeset for help on using the changeset viewer.