Conditional hiding of rows

Posted by: fritzela on 8 September 2017, 12:48 pm EST

  • Posted 8 September 2017, 12:48 pm EST

    I have a spread bound to a custom collection.  When the form loads, I want to set the Visible property of each row based on the value in the Status column ( 0 = open, 4= closed) and the value of  a boolean ShowClosedOrders property of the form.  Once the form is loaded, the user can hit a toggle button to change the value of the ShowClosedOrders property to hide or show closed orders.  Right now, I am using the following code to do this:

     
    foreach(FarPoint.Win.Spread.Row row in fpSpread1_Sheet1.Rows)
    {
       row.Visible = (((int)fpSpread1_Sheet1.Cells[row.Index,11].Value != 4) | showCompletedOrders);
    }

     Iterating through the rows takes too long.  For a sheet of fifty rows, it can take as long as 20 seconds.  Is there a faster way to do this?  By the way, there are two columns on the spread that use formulas.


    I am using FarPoint Spread For Windows V2.5


    Thanks for your help.


     


     

  • Replied 8 September 2017, 12:48 pm EST

    One other thing to consider is if you have alot of styles set for the cells.  If possible try to assign them at the DefaultStyle level or at the column and row level rather than at the cell level.
  • Replied 8 September 2017, 12:48 pm EST

    Hello,


    One more thing to turn off during this process to make the painting faster is the AutoUpdateNotes property.

  • Replied 8 September 2017, 12:48 pm EST

    You can try calling SuspendLayout before you decide on the visibility of the rows and then call ResumeLayout when you are finished.  You can also try calling SuspendFormulaParsing beforehand and then call ResumeFormulaParsing when finished.
  • Replied 8 September 2017, 12:48 pm EST

    Thanks, Bob.  Your suggestions helped.  The spreadsheet still redraws more slowly than I would like, but it is a lot faster than before.


     


     


     

  • Replied 8 September 2017, 12:48 pm EST

    I have already tried setting the AutoUpdateNotes property to false, and all of my cell formats are set at the column level.  These things didn't make a noticible difference.  The only major change between this verison of my app and an earlier one in which the spreadsheet loaded quickly is that I use formulas in two cells.  Here's the code I use to bind the datasource:

     
    fpSpread1_Sheet1.AutoGenerateColumns = false;
    fpSpread1_Sheet1.DataAutoCellTypes = false;
    fpSpread1_Sheet1.DataAutoHeadings = false;
    fpSpread1_Sheet1.DataAutoSizeColumns = false;
    fpSpread1_Sheet1.AutoUpdateNotes = false;
    fpSpread1_Sheet1.ReferenceStyle = ReferenceStyle.R1C1;

    fpSpread1_Sheet1.DataSource = null;

    for(int i=0;i

    {

    fpSpread1_Sheet1.BindDataColumn(i,null);

    }


    fpSpread1_Sheet1.DataSource = fCurrentSchedule.WorkOrders;

    fpSpread1_Sheet1.BindDataColumn(0,"ProdScheduleKey");
    fpSpread1_Sheet1.BindDataColumn(1,"Sequence");
    fpSpread1_Sheet1.BindDataColumn(2,"PartNumber");
    fpSpread1_Sheet1.BindDataColumn(3,"CAP");
    fpSpread1_Sheet1.BindDataColumn(4,"Grit");
    fpSpread1_Sheet1.BindDataColumn(5,"Width");
    fpSpread1_Sheet1.BindDataColumn(6,"OrderNumber");
    fpSpread1_Sheet1.BindDataColumn(7,"Yards");
    fpSpread1_Sheet1.BindDataColumn(8,"DueDate");
    fpSpread1_Sheet1.BindDataColumn(9,"Operation");
    fpSpread1_Sheet1.BindDataColumn(11,"Status");
    fpSpread1_Sheet1.BindDataColumn(12,"ProductionScheduler");
    fpSpread1_Sheet1.BindDataColumn(13,"HasNotes");
    fpSpread1_Sheet1.BindDataColumn(15,"IsExperiment");
    fpSpread1_Sheet1.Columns[10].Formula = "IF(OR(RC12=4,RC12=3),1,0)";
    fpSpread1_Sheet1.Columns[14].Formula = "IF((RC14=1),1,0)";
    fpSpread1_Sheet1.RecalculateAll();

    fpSpread1_Sheet1.Columns[7].Locked = !(fUser == SchedulerUser.Planner);
     
    Columns 10 and 14 are checkboxes that are set based on the values of Status and HasNotes.
    Don't know if this is what is slowing stuff up.
  • Replied 8 September 2017, 12:48 pm EST

    Hello,


    I do not see anything that woudl cause the 20 seconds to hide rows as you are seeing. Could you post a small zipped project reproducing this for us to debug?

  • Replied 8 September 2017, 12:48 pm EST

    Scott,


    Before I had a chance to send you a zipped project, I loaded  v 3.0 and the problem disappeared without any changes to my code (I was using 2.5).  It appears that whatever the problem was, it is already fixed.


    Thanks for your help.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels