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:<FONT color=#008000 size=2>

    <SPAN class=kwd>foreach</SPAN>(FarPoint.Win.Spread.Row row <SPAN class=kwd>in</SPAN> fpSpread1_Sheet1.Rows)
       row.Visible = (((<SPAN class=kwd>int</SPAN>)fpSpread1_Sheet1.Cells[row.Index,11].Value != 4) | showCompletedOrders);
    <P> 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

    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 <span id="pagetitle">SuspendFormulaParsing beforehand and then call </span><span id="pagetitle">ResumeFormulaParsing when finished.
  • 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


    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

    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 = <SPAN class=kwd>false</SPAN>;
    fpSpread1_Sheet1.DataAutoCellTypes = <SPAN class=kwd>false</SPAN>;
    fpSpread1_Sheet1.DataAutoHeadings = <SPAN class=kwd>false</SPAN>;
    fpSpread1_Sheet1.DataAutoSizeColumns = <SPAN class=kwd>false</SPAN>;
    fpSpread1_Sheet1.AutoUpdateNotes = <SPAN class=kwd>false</SPAN>;
    fpSpread1_Sheet1.ReferenceStyle = ReferenceStyle.R1C1;
    <FONT size=2><P>fpSpread1_Sheet1.DataSource = </FONT><FONT color=#0000ff size=2>null</FONT><FONT size=2>;

    </FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>(</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> i=0;i<fpSpread1_Sheet1.Columns.Count;i++)


    fpSpread1_Sheet1.BindDataColumn(i,</FONT><FONT color=#0000ff size=2>null</FONT><FONT size=2>);


    fpSpread1_Sheet1.DataSource = fCurrentSchedule.WorkOrders;

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

    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.
    <FONT face="Times New Roman">Don't know if this is what is slowing stuff up.</FONT>
  • Replied 8 September 2017, 12:48 pm EST


    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


    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.

  • 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.




Need extra support?

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

Learn More

Forum Channels