Skip to content

RemoveAt Method

Description

Removes the record and row at the specified position in the collection of records.

Syntax

Public Sub RemoveAt( _
    ByVal [Index](#) As Long _
)

Parameters

Remarks

Removes/deletes a row/record by its index. To remove a row from the GridControl, the Record attached to the row must be removed. This will permanently remove the row/record from the GridControl's collection of rows and collection of records.

Example

Using the RemoveAt Method to Remove a Row (Visual Basic)

This sample illustrates how to remove a row from the GridControl. To remove a row, you must remove the Record that is attached to the row. This sample uses the KeyDown event to determine when the Delete key is pressed. If the Delete key is pressed, all selected rows are removed.

' You can use the KeyDown event to determine when the delete key is pressed, then you can  
' remove any selected rows from the GridControl  

Private Sub wndGridControl_KeyDown(KeyCode As Integer, Shift As Integer)  
    On Error Resume Next  

    ' If the delete key is pressed (Delete's keycode = 46) then remove all selected rows  
    If (KeyCode = 46) Then  
        Dim Row As GridRow  

        ' Enumerate through each selected row in the GridControl's collection of selected rows  
        For Each Row In wndGridControl.SelectedRows  
            ' Removes the selected row; to remove a row, you must remove the record attached to the row  
            wndGridControl.Records.RemoveAt (Row.Record.Index)  
        Next  

        ' Any time you add or delete rows (by removing the attached record), you must call the  
        ' Populate method so the GridControl will display the changes. The rows will remain  
        ' visible until the Populate method is called  
        wndGridControl.Populate  
    End If  
End Sub

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.