We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to Insert or Delete rows

How can I insert a row (and have all rows below it shift down automatically) and also delete a row and have all rows below it shift up? Thanks

3 Replies

CB Clay Burch Syncfusion Team September 10, 2002 01:22 AM

To remove rows in a GridControl, use the GridControl.Rows.RemoveRange method. To insert rows into a GridControl, use the GridControl.Rows.InsertRange method. For a GridDataBoundGrid, the methods are GridDataBoundGrid.Binder.RemoveRecords and GridDataBoundGrid.Binder.AddNew.


TE Thomas Eyde November 19, 2002 02:27 AM

Thank you. But I guess I have to be more precise. How do I invoke the deletion from the GUI? I like to select one or more rows, then press the delete button. But I can't find the proper event.


AD Administrator Syncfusion Team November 19, 2002 02:50 AM

Try handling the CurrentCellKeyDown event.
Private Sub GridControl1_CurrentCellKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GridControl1.CurrentCellKeyDown
        If e.KeyCode = Keys.Delete Then
            Dim range As GridRangeInfo = Me.GridControl1.Selections.Ranges.ActiveRange
            If range.IsRows Then
                Me.GridControl1.Rows.RemoveRange(range.Top, range.Bottom)
                e.Handled = True
            End If
        End If
    End Sub

Loader.
Live Chat Icon For mobile
Up arrow icon