CellRange Border

Posted by: arungk on 8 September 2017, 1:00 pm EST

  • Posted 8 September 2017, 1:00 pm EST

    Hi,


    I need to apply border for a range of cells selected. I'm doing this in SelectionChanging event as the border should be applied for every move in selection.


    Now my problem is, if I select a different range how do I reset the border for the previous cellrange?


    Arun.G.K

  • Replied 8 September 2017, 1:00 pm EST

    Arun -

    One thing you can try is to use the LeaveCell event and in it call the ResetBorder method on the Cell level.  Or you could set a global flag and set it to false and then in the SelectionChanging event set it to true and query its status and if it's true then call the ResetBorder then set the flag back to false so it won't remove the selection you are beginning.
  • Replied 8 September 2017, 1:00 pm EST


    Bob,


    Thanks for your help. I need the exact functionality as in the excel sheet. Take a look at my code


    Private Sub FpSpread1_SelectionChanging(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.SelectionChangingEventArgs) Handles FpSpread1.SelectionChanging


    Dim lineBorder As New LineBorder(Color.Black, 3)



    FpSpread1.ActiveSheet.SetOutlineBorder(e.Range, lineBorder)


    End Sub


    Private Sub FpSpread1_SelectionChanged(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.SelectionChangedEventArgs) Handles FpSpread1.SelectionChanged


    Dim lineBorder As New LineBorder(Color.Black, 3)


    FpSpread1.ActiveSheet.SetOutlineBorder(e.Range, lineBorder)


    End Sub


    ' This will remove border of one cell alone. But I need to reset the border for the whole range, when the range is deselected (which happens when I select someother cell)


    Private Sub FpSpread1_LeaveCell(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.LeaveCellEventArgs) Handles FpSpread1.LeaveCell


    FpSpread1.ActiveSheet.Cells(e.Row, e.Column).ResetBorder()


    End Sub


    Arun.G.K

  • Replied 8 September 2017, 1:00 pm EST

     Arun -

    I would suggest you change the Cells call to be 0,0,FpSpread1.ActiveSheet.RowCount - 1, FpSpread1.ActiveSheet.ColumnCount - 1.

    This way it will clear any border that is present in the sheet.
Need extra support?

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

Learn More

Forum Channels