Cell Error icon not being updated after sort

  • ericjwo 2 weeks, 5 days ago

    I am having problem with the cell error icon not being updated to the correct row after sorting. For example, I set both the row and cell error on a row, but after sorting, only the row error icon is moved. The cell error icon stays on the old row, even though I can hover over the cell on the correct row and see the error text. This must be a bug in how the error icon is painted for cells.

    The code below will reproduce what I am seeing. I tried multiple ways to do the sorting, including the automatic sorting method, and calling SortRows after clicking the column header. I also created a method called mUpdateError() which actually loops through all the rows and explicitly sets the row and cell error for the correct row. Even after doing that, and invalidating the cell to ensure it is redrawn, the error icon does not show up for the correct cell.

    public frmMain()
    {
    InitializeComponent();

    // add data to grid

    // column 1
    fpSpread1.ActiveSheet.Cells[0, 0].Value = “ABC”;
    fpSpread1.ActiveSheet.Cells[1, 0].Value = “DEF”;
    fpSpread1.ActiveSheet.Cells[2, 0].Value = “GHI”;
    fpSpread1.ActiveSheet.Cells[3, 0].Value = “JKL”;
    fpSpread1.ActiveSheet.Cells[4, 0].Value = “XYZ”;

    // column 2
    fpSpread1.ActiveSheet.Cells[0, 1].Value = “XYZ”;
    fpSpread1.ActiveSheet.Cells[1, 1].Value = “JKL”;
    fpSpread1.ActiveSheet.Cells[2, 1].Value = “GHI”;
    fpSpread1.ActiveSheet.Cells[3, 1].Value = “DEF”;
    fpSpread1.ActiveSheet.Cells[4, 1].Value = “ABC”;

    fpSpread1.ShowCellErrors = true;
    fpSpread1.ShowRowErrors = true;

    mUpdateError();

    bool autoSort = true;

    if (autoSort)
    {
    fpSpread1.ActiveSheet.SetColumnAllowAutoSort(0, true);
    fpSpread1.ActiveSheet.SetColumnShowSortIndicator(0, true);
    fpSpread1.ActiveSheet.SetColumnAllowAutoSort(1, true);
    fpSpread1.ActiveSheet.SetColumnShowSortIndicator(1, true);

    fpSpread1.AutoSortedColumn += (sender, e) =>
    {
    mUpdateError();
    };
    }
    else
    {
    fpSpread1.CellClick += (sender, e) =>
    {
    if (e.ColumnHeader)
    {
    switch (fpSpread1.ActiveSheet.Columns[e.Column].SortIndicator)
    {
    case FarPoint.Win.Spread.Model.SortIndicator.None:
    fpSpread1.ActiveSheet.SortRows(e.Column, true, true);
    break;
    case FarPoint.Win.Spread.Model.SortIndicator.Ascending:
    fpSpread1.ActiveSheet.SortRows(e.Column, false, true);
    break;
    default:
    fpSpread1.ActiveSheet.Models.ResetViewRowIndexes();
    fpSpread1.ActiveSheet.Columns[e.Column].SortIndicator = FarPoint.Win.Spread.Model.SortIndicator.None;
    break;
    }

    mUpdateError();
    }
    };
    }
    }

    private void mUpdateError()
    {
    for (int i=0; i<5; i++)
    {
    if (fpSpread1.ActiveSheet.Cells.Value != null && string.Compare(fpSpread1.ActiveSheet.Cells.Value.ToString(), "DEF", false) == 0)
    {
    fpSpread1.ActiveSheet.SetCellErrorText(i, 1, "row: " + i + ", col: 1, error on DEF");
    fpSpread1.ActiveSheet.SetRowErrorText(i, "row: " + i + ", error on DEF");

    fpSpread1.ActiveSheet.Cells.Invalidate();
    }
    else
    {
    fpSpread1.ActiveSheet.SetCellErrorText(i, 1, string.Empty);
    fpSpread1.ActiveSheet.SetRowErrorText(i, string.Empty);

    fpSpread1.ActiveSheet.Cells.Invalidate();
    }
    }
    }
    }

  • 117p
    Sean Lawyer117p 2 weeks, 5 days ago

    Hi,

    Can you post a small sample to clarify the code you’re using? I think some code might have got mangled by the forum — there is no Value property defined for the Cells class, and it’s not clear which indexes should be passed to the indexer to specify a Cell object.

    Regards,
    -Sean

  • ericjwo 2 weeks, 5 days ago

    I’m using Spread 9.35.20153.0, maybe that’s the reason for the confusion.

  • ericjwo 2 weeks, 5 days ago

    There is a Value property for Cells.

    http://sphelp.grapecity.com/WebHelp/SpreadNet10/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.Cell~Value.html

    It seems pretty straightforward to me. Also, Cells[row, column] is pretty standard too, isn’t it? I’m not sure what I can do to clear things up.

  • ericjwo 2 weeks, 5 days ago

    Try this simplified snippet. It simply fills in some data and adds a row error to row 3 and a cell error to cell 3,1. After you sort, the row error is moved correctly, but the cell error icon is left behind. The cell error text is in the correct place, in the new row after being sorted, but the icon is left behind in its old position.

    fpSpread1.ActiveSheet.Cells[0, 0].Value = “ABC”;
                fpSpread1.ActiveSheet.Cells[1, 0].Value = “DEF”;
                fpSpread1.ActiveSheet.Cells[2, 0].Value = “GHI”;
                fpSpread1.ActiveSheet.Cells[3, 0].Value = “JKL”;
                fpSpread1.ActiveSheet.Cells[4, 0].Value = “XYZ”;
    
                // column 2
                fpSpread1.ActiveSheet.Cells[0, 1].Value = “XYZ”;
                fpSpread1.ActiveSheet.Cells[1, 1].Value = “JKL”;
                fpSpread1.ActiveSheet.Cells[2, 1].Value = “GHI”;
                fpSpread1.ActiveSheet.Cells[3, 1].Value = “DEF”;
                fpSpread1.ActiveSheet.Cells[4, 1].Value = “ABC”;
    
                fpSpread1.ShowCellErrors = true;
                fpSpread1.ShowRowErrors = true;
    
                fpSpread1.ActiveSheet.SetCellErrorText(3, 1, “row: 3, col: 1, error on DEF”);
                fpSpread1.ActiveSheet.SetRowErrorText(3, “row: 3, error on DEF”);
    
                    fpSpread1.ActiveSheet.SetColumnAllowAutoSort(0, true);
                    fpSpread1.ActiveSheet.SetColumnShowSortIndicator(0, true);
                    fpSpread1.ActiveSheet.SetColumnAllowAutoSort(1, true);
                    fpSpread1.ActiveSheet.SetColumnShowSortIndicator(1, true);
  • 23p
    GinaDan23p 2 weeks, 4 days ago

    Hi,

    This looks like it might have been a bug in V9. I tried the current V10 and it seems to work fine. Are you expecting the result in the images?

    Thanks, Gina

    Attachments:
    You must be logged in to view attched files.
  • ericjwo 2 weeks, 4 days ago

    Your pictures are the correct behavior. Upgrading to Spread 10 did indeed fix the problem. Thanks.

  • 23p
    GinaDan23p 2 weeks, 4 days ago

    Thanks for letting us know this has been resolved.

    -Gina

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to create new topics.