Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3335 for trunk/sources


Ignore:
Timestamp:
04/13/10 18:27:45 (15 years ago)
Author:
mkommend
Message:

fixed bugs in IStringConvertibleMatrixView (ticket #968)

File:
1 edited

Legend:

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

    r3328 r3335  
    104104      columnsTextBox.Enabled = true;
    105105      virtualRowIndizes = Enumerable.Range(0, Content.Rows).ToArray();
    106       dataGridView.RowCount = Content.Rows;
    107       dataGridView.ColumnCount = Content.Columns;
     106      //DataGridViews with Rows but no columns are not allowed !
     107      if (Content.Rows == 0 && dataGridView.RowCount != Content.Rows)
     108        Content.Rows = dataGridView.RowCount;
     109      else
     110        dataGridView.RowCount = Content.Rows;
     111      if (Content.Columns == 0 && dataGridView.ColumnCount != Content.Columns)
     112        Content.Columns = dataGridView.ColumnCount;
     113      else
     114        dataGridView.ColumnCount = Content.Columns;
    108115      UpdateRowHeaders();
    109116      UpdateColumnHeaders();
     
    153160        Invoke(new EventHandler<EventArgs<int, int>>(Content_ItemChanged), sender, e);
    154161      else
    155         dataGridView.InvalidateCell(e.Value, e.Value2);
     162        dataGridView.InvalidateCell(e.Value2, e.Value);
    156163    }
    157164    private void Content_Reset(object sender, EventArgs e) {
     
    172179    private void rowsTextBox_Validating(object sender, CancelEventArgs e) {
    173180      int i = 0;
    174       if (!int.TryParse(rowsTextBox.Text, out i) || (i < 0)) {
     181      if (!int.TryParse(rowsTextBox.Text, out i) || (i <= 0)) {
    175182        e.Cancel = true;
    176         errorProvider.SetError(rowsTextBox, "Invalid Number of Rows (Valid Values: Positive Integers Larger or Equal to 0)");
     183        errorProvider.SetError(rowsTextBox, "Invalid Number of Rows (Valid values are positive integers larger than 0)");
    177184        rowsTextBox.SelectAll();
    178185      }
     
    194201    private void columnsTextBox_Validating(object sender, CancelEventArgs e) {
    195202      int i = 0;
    196       if (!int.TryParse(columnsTextBox.Text, out i) || (i < 0)) {
     203      if (!int.TryParse(columnsTextBox.Text, out i) || (i <= 0)) {
    197204        e.Cancel = true;
    198         errorProvider.SetError(columnsTextBox, "Invalid Number of Columns (Valid Values: Positive Integers Larger or Equal to 0)");
     205        errorProvider.SetError(columnsTextBox, "Invalid Number of Columns (Valid values are positive integers larger than 0)");
    199206        columnsTextBox.SelectAll();
    200207      }
     
    239246    private void dataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {
    240247      int rowIndex = virtualRowIndizes[e.RowIndex];
    241       e.Value = Content.GetValue(rowIndex, e.ColumnIndex);
    242     }
    243 
     248      if (e.RowIndex < Content.Rows && e.ColumnIndex < Content.Columns)
     249        e.Value = Content.GetValue(rowIndex, e.ColumnIndex);
     250    }
    244251    private void dataGridView_Scroll(object sender, ScrollEventArgs e) {
    245252      UpdateRowHeaders();
    246253    }
    247 
    248254    private void dataGridView_Resize(object sender, EventArgs e) {
    249255      UpdateRowHeaders();
Note: See TracChangeset for help on using the changeset viewer.