Remove focus from Spread

Posted by: sameek on 8 September 2017, 1:08 pm EST

  • Posted 8 September 2017, 1:08 pm EST

    I have two comboboxes and a spread on my control.  The spread is databound.  If a cell in the spread has an error then a property is set for the spread.  If that property is true and a user tries to click off of the spread then I want to prevent them from doing this.  I have tried the Leave event of the spread but that does not seem to fire when I click off of the spread.  Any ideas would be great.  Thanks.

  • Replied 8 September 2017, 1:08 pm EST

    mmeek -

    If you use the LeaveCell event and check the validation of the cell then you should be able to set the e.Cancel in the event to true.  Have you tried that?  If so, can you post a small project reproducing this for us to debug.
  • Replied 8 September 2017, 1:08 pm EST

    Yes, I have e.cancel in the LeaveCell event, and while that does prevent you from leaving the cell on the spread, it does allow you to move off of the spread and do other things.  I was thinking that there may be a way to prevent them from leaving the spread?
  • Replied 8 September 2017, 1:08 pm EST


    You need to use the Validating event to keep focus from leaving a control.

      Private Sub FpSpread1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles FpSpread1.Validating
    e.Cancel = True
    End Sub
Need extra support?

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

Learn More

Forum Channels