How to remove a row and enable the delete key if checkbox is selected in VB 6.0 flexgrid

In the VB 6.0 flexgrid, if the user like to be able to select the check box and press the delete key to delete the row, how do you do that? Could you provide the codes?

Thank you in advance!
ja-vic
ja-vicAsked:
Who is Participating?
 
PaulHewsCommented:
Simple example

Private Sub Form_Load()
    Dim i As Integer
    With MSFlexGrid1
        .FixedRows = 1
        .FixedCols = 0
        .Rows = 1
        .Cols = 1
        .TextMatrix(0, 0) = "Heading"
        For i = 1 To 20
            .AddItem "Item " & i
        Next i
   
    End With
End Sub

Private Sub MSFlexGrid1_KeyUp(KeyCode As Integer, Shift As Integer)
    If chkAllowDelete.Value = 1 Then
       If KeyCode = vbKeyDelete Then
            With MSFlexGrid1
                If .Row > 0 And .Rows > 2 Then  'dont remove header or last row other than header
                    .RemoveItem .Row
                End If
            End With
        End If
       
    End If
End Sub
0
 
ja-vicAuthor Commented:
Hi,

Thank you for the example. It helps!

ja-vic
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.