delete selected cell range

Posted by: lg_sony_27 on 8 September 2017, 1:21 pm EST

  • Posted 8 September 2017, 1:21 pm EST

    Hi!


    i would like to delete the values of a selected range of cell when pressing del key. I tried selecting a range of cell and press the deleter key but only one value is deleted. Is this possible?


    thanks!

  • Replied 8 September 2017, 1:21 pm EST

    You would need to use the GetSelection method which will return a CellRange and then use the CellRange co-ordinates returned as the indices for the Cells and set the Value for those cells to an empty string.
  • Replied 8 September 2017, 1:21 pm EST

    any sample code here and what event where do i put it?
  • Replied 8 September 2017, 1:21 pm EST

    Here's the easiest way...

    Private Sub FpSpread1_SelectionChanged(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.SelectionChangedEventArgs) Handles FpSpread1.SelectionChanged
    Dim r As FarPoint.Win.Spread.Model.CellRange
    r = e.Range

    e.View.Sheets(0).ClearRange(r.Row, r.Column, r.RowCount, r.ColumnCount, True)

    End Sub

  • Replied 8 September 2017, 1:21 pm EST

    i am getting this error by just merely selecting range of cell "Object reference not set to an instance of an object."

  • Replied 8 September 2017, 1:21 pm EST

    What line is throwing the error?
  • Replied 8 September 2017, 1:21 pm EST

    this line


    e.View.Sheets(0).ClearRange(r.Row, r.Column, r.RowCount, r.ColumnCount, True)

  • Replied 8 September 2017, 1:21 pm EST

    This is working correctly in my test.  Can you post a small project showing the behavior you are seeing?
  • Replied 8 September 2017, 1:21 pm EST

    I think you misunderstood my question BobM. This I what I want to happen. I will select (highlight) a range of cell and then press the delete key to delete all the contents of the selected cells.


    Your code will erase the contents of the cells whenever i move the focus on the cells.

  • Replied 8 September 2017, 1:21 pm EST

    You can do the following...

    Dim im As FarPoint.Win.Spread.InputMap
    im = FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
    im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Delete, Keys.None), FarPoint.Win.Spread.SpreadActions.ClearSelectedCells)
     

  • Replied 8 September 2017, 1:21 pm EST

    Thanks! perfect!
Need extra support?

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

Learn More

Forum Channels