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

Posted on 2005-04-06
Last Modified: 2006-11-18
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!
Question by:ja-vic
    LVL 38

    Accepted Solution

    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

    Author Comment


    Thank you for the example. It helps!


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Watch V6 5 42
    VB6 convert MSHFlexgrid1 cells no2 2 34
    Restricting text box entry from \/:?<>"| 9 52
    VB error "Type mismatch" 2 30
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now