[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

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
0
ja-vic
Asked:
ja-vic
1 Solution
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now