Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006

    Unanswered: Add Edit Delete Options on right click in MSFlexGrid Control VB6

    Hi: Can any one please tell me how to enable a right click option in MSFlexGrid Control. I mean when user right click in any grid row, it ask option Add, Edit, Delete and when user click on any one of them another form will be open and load the values from that row into new form.


  2. #2
    Join Date
    Feb 2007
    Hi, you can do it this way:
    Create a form with MSFlexGrid1 control (several rows and columns).
    Prepare your menu - activate the form and use Tools - Menu Editor. Define the items of the menu. The main item called MojeMenu is not visible, subitems are called Add, Edit, Delete in my case.
    Here is the code. The Edit_Click() sub is not defined but you can do like other subs.

    Dim Rada As Integer
    Option Explicit
    Private Sub Add_Click()
    MSFlexGrid1.AddItem "", Rada + 1
    End Sub
    Private Sub Delete_Click()
    MSFlexGrid1.RemoveItem Rada
    End Sub
    Private Sub Form_Load()
    Dim I As Integer
    MSFlexGrid1.Col = 0
    For I = 0 To MSFlexGrid1.Rows - 1
        MSFlexGrid1.Row = I
        MSFlexGrid1.Text = I
    Next I
    End Sub
    Private Sub MSFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 2 Then   ' Check if right mouse button was clicked.
        Rada = Int((y) / (MSFlexGrid1.RowHeight(1)))
        PopupMenu MojeMenu   ' Display the menu as a pop-up menu.
    End If
    End Sub
    Last edited by loquin; 02-05-07 at 17:16. Reason: add [code] [/code] tags for readability.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts