Setting Focus To Specific Row and Column (Specific Cell)

Posted by: reflaherty on 8 September 2017, 1:46 pm EST

  • Posted 8 September 2017, 1:46 pm EST

    Using Spread for Windows (C# 3.5 - Spread 4.0.3505.2008).  Have a multiple row/ multiple column spread.  A few of the columns I have set to unlock so that the user could make changes to the data.  When the user either navigates to a different row (LeaveCell event where the row is not equal to the newRow) or the spread looses focus (Leave event) and there has been a change, I validate the data in the row being left.  When errors are found, I display the error message or messages.

    What I have not figured out is how to set the focus back to the row just being left.  I tired fpSpread1.SetViewportTopRow, fpSpread1.SetViewportLeftCoumn, fpSpread1_Sheet1.SetActiveCell and setting the fpSpread1_Sheet1.ActiveRowIndex to the targeted row.  The SetViewportLeftCoumn scrolls left-to-right but the row focus stays on the new row.

  • Replied 8 September 2017, 1:46 pm EST


    Have you tried using the <span id="pagetitle"><b>RetainSelectionBlock </b>property of the control ?</span>



  • Replied 8 September 2017, 1:46 pm EST


    In the LeaveCell event, you do not need to do any of this extra code. All you need to do is to set the e.Cancel parameter to True and Spread will cancel the moving of the active cell. For the losing focus event, you need to move your code to validate to the validating event of Spread and set the Cancel parameter in that event to True if you do not want to lose focus.

Need extra support?

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

Learn More

Forum Channels