CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 1999
    Location
    Texas
    Posts
    96

    Popup Menu Problem

    Here's the problem:
    I have a form that has a listview that displays a recordset. The user can double-click on a specific listitem which brings up another form to edit the data. They can also right-click on the listview and choose Edit from a popup menu. Either way, the same popup dialog window is shown. The problem is, if the user accesses the new form via the popup menu, I can not display a popup menu on the new form, however if they simply double-click on the item, when the new form is loaded, the popup menu is displayed just fine.

    Does anyone know of a work-around for this or why it is happening?


  2. #2
    Join Date
    Sep 1999
    Posts
    202

    Re: Popup Menu Problem

    One solution is here:
    http://www.**************/Item.asp?PageID=BugBank&ID=3

    but I think this is better:
    Do not execute action (show form) in menu_Click event.
    Instead, just return value to the function which called PopupMenu and execute action in that caller function:


    ' Form1 code
    option Explicit

    private Sub Form_MouseUp(Button as Integer, Shift as Integer, X as Single, Y as Single)
    Dim strSelection as string
    If Button = vbRightButton then
    Load frmpopups
    ' you can check/uncheck menu items here or in frmPopups
    ' show popup menu
    PopupMenu frmpopups.mnuPop
    ' get selection
    strSelection = frmpopups.Selection
    Unload frmpopups
    '
    ' execute action here
    Select Case strSelection
    Case "Edit"
    ' frmEdit.Show vbModal
    Case "Delete", "Refresh"
    ' do something
    End Select
    End If
    End Sub
    '----------------------------------------------
    ' frmPopups Form
    ' Contains popup menu for Listview
    ' mnuPop
    ' mnuEdit
    ' mnuDelete
    ' mnuRefresh
    option Explicit
    private mSelection as string
    private Sub Form_Load()
    mSelection = ""
    End Sub
    public property get Selection() as string
    Selection = mSelection
    End property
    private Sub mnuDelete_Click()
    mSelection = "Delete"
    End Sub
    private Sub mnuEdit_Click()
    mSelection = "Edit"
    End Sub
    private Sub mnuRefresh_Click()
    mSelection = "Refresh"
    End Sub





Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured