ver. 4 locking cells

Posted by: pscott on 8 September 2017, 1:36 pm EST

  • Posted 8 September 2017, 1:36 pm EST

    Hi,


     I have a project build with v. 2.5.  I have code that locks certain cell from editing, and allows others to be unlocked to allow editing.  The application has been working stabily over several releases.


    I updated to V4 today.  All my cells are locked.  On the design surface, Spread is set to not locked.


    Is there something I'm missing here?


     Pete

  • Replied 8 September 2017, 1:36 pm EST

    Bob,


     I am using an Excel template.  The editable cells are unlocked, the non-editable ones locked.  I load this template from the disk, then set protection = true in the code.  At that point, all the cells in the workbook are non-editable.


    I am setting the cursor type with the following code:

    <FONT size=2>

    mworkbook.SetCursor(FarPoint.Win.Spread.CursorType.Normal, System.Windows.Forms.Cursors.Arrow)


    mworkbook.SetCursor(FarPoint.Win.Spread.CursorType.LockedCell, System.Windows.Forms.Cursors.No)


    The EditModeReplace is set to true.


    I have a status bar on the form that contains the spreadsheet to show the user whether the cell is locked or not.  That display is controlled in the 'enter_cell' event:

    <FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.FpSpread1.Sheets(1).Cells(e.Row, e.Column).Locked </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Then

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.BarStaticItem12.Caption = </FONT><FONT color=#800000 size=2><FONT color=#800000 size=2>"Locked"

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Else

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.BarStaticItem12.Caption = </FONT><FONT color=#800000 size=2><FONT color=#800000 size=2>""

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT>


    <FONT color=#0000ff size=2><FONT color=#0000ff size=2>When the application runs, the status correctly shows whether the cell is locked or not.  I cannot edit any of the cells that are not displayed as locked in the status bar.  But the cursor always remains as the windows.no</FONT></FONT>


    <FONT color=#0000ff size=2><FONT color=#0000ff size=2>Here is the funny part: I have an executable on my development machine that is compiled with version 2.5 Spread.  It has been working fine as a demo app.  Now that version 4.0 is on the workstation, the executable exhibits the same problem.</FONT></FONT>


    <FONT color=#0000ff size=2><FONT color=#0000ff size=2> Any ideas?</FONT></FONT>


    <FONT color=#0000ff>Peter<FONT size=2><FONT size=2>

    </FONT></FONT></FONT></FONT>
  • Replied 8 September 2017, 1:36 pm EST

    Bob,


     More information: If I don't protect the worksheet, I can edit all the cells, locked or not.  This is as expected.  But, if I protect the worksheet, none of the cells are editable.  Even those that are identified with the enter_cell event as unlocked.


    Pete

  • Replied 8 September 2017, 1:36 pm EST

    Pete -

    I am not sure I am following what you are doing here.  Can you attach a small project that shows this behavior and the steps needed to reproduce it.

  • Replied 8 September 2017, 1:36 pm EST

    Bob,


     I'll attach a test project that shows this behavior shortly.  Basically, when I have an Excel workbook that I read into spread on a winform with the .openexcel method, v4 does not recognize the locked cells.  After opening it, if I unlock the cells in code and protect the workbook, then the cell locking/unlocking works properly.


    If I use the spread designer to create an workbook on the form with locked and unlocked cells, the locking works as expected when I protect the workbook at runtime.


     The thing that is driving me crazy is that spread v2.5 did not exhibit this behavior.  I am upgrading an existing application and must use V4 to support translation in Arabic.  I have a series of worksheets with thousands of cells, and did not expect to have to code ranges of cells to lock/unlock.


    Pete

  • Replied 8 September 2017, 1:36 pm EST

    Peter -

    In v 2.5 how were you locking the cells?  This should not have changed between versions.

  • Replied 8 September 2017, 1:36 pm EST

    Pete,


    The project did not attach to this thread. Make sure it is zipped and less than 256KB. Could you reattach the project or email it to fpsupport@fpoint.com?

Need extra support?

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

Learn More

Forum Channels