Results 1 to 6 of 6

Thread: unloading popup menuitem error

  1. #1

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    unloading popup menuitem error

    when ever i try to unload a menu item from the popup menu item under combbox click event like this

    vb Code:
    1. For i = mnuTCategory.Count - 1 To 1 Step -1
    2.        Unload mnuTCategory(i)
    3. Next

    I get this error "Unable to unload within this context". Can someone show me how to do this
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: unloading popup menuitem error

    Never worked this before...but will research...Can you remove ONE item, like: unload mnuTCategory(2) ? In meantime, will check this out.

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: unloading popup menuitem error

    Well, after just an initial research and test, if mnuTCategory is the name of your invisible top menuitem (which you display using the popupmenu function), then it has no .count property. So that approach would be incorrect from the start. Still researching (are you?)

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: unloading popup menuitem error

    Not sure if this will work for you, however, it is a solution of sorts.
    First, I have a listbox and a commandbutton on my form...
    I then have a menu item called: MnuListPopup
    Under that, I have two additional sub-menus: mnuHide and mnuShow
    (created that using the menuEditor, and of course set MnListPopup to NOT visible---leaving the two sub menus as VISIBLE)

    Then I put in this code on the listbox:

    Code:
    Private Sub List1_MouseDown(Button As Integer, Shift As Integer, _
    X As Single, Y As Single)
    If Button And vbRightButton Then
         PopupMenu MnuListPopup
    End If
    End Sub
    Then, in my example, I put the cmd button's click event as:

    Code:
    mnuHide.Visible = False
    Before clicking the button, I see both Hide and Show options when I right click on my list box
    After clicking the buttion, of course I only see the Show option (as mnuHide is now invisible).

    Can you use this approach somehow?

  5. #5

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: unloading popup menuitem error

    {delete}
    Last edited by coolcurrent4u; Jan 28th, 2013 at 03:00 PM.
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  6. #6

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: unloading popup menuitem error

    thanks for your response, the top menu created in design mode is mnuTCategories,
    In the submenu mnuTCategory, i added one item mnuTCategory(0) at design time and the rest loaded at runtime .
    so in total mnuTCategory contacts 3 menus. but i cannot unload any of them at runtime

    what am doing is removing all and reloading another set of items, but it wont allow me to do that
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

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