ver. 4 locking cells

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

  • Posted 8 September 2017, 1:36 pm EST


     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?


  • Replied 8 September 2017, 1:36 pm EST


     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:

    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:

    If Me.FpSpread1.Sheets(1).Cells(e.Row, e.Column).Locked Then

    Me.BarStaticItem12.Caption = "Locked"


    Me.BarStaticItem12.Caption = ""

    End If

    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

    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.

     Any ideas?


  • Replied 8 September 2017, 1:36 pm EST


     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.


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

    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


     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.


  • Replied 8 September 2017, 1:36 pm EST


    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

Need extra support?

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

Learn More

Forum Channels