从弹出菜单中卸载项目错误 [英] unloading items from popup menu error

查看:18
本文介绍了从弹出菜单中卸载项目错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误

无法在此上下文中卸载"

"Unable to unload within this context"

每当我尝试像他一样从弹出菜单中卸载菜单项时

when ever i try to unload a menu item from the popupmenu like his

For i = mnuTCategory.Count - 1 To 1 Step -1
       Unload mnuTCategory(i)
Next

有没有办法做到这一点而不出现这个错误>?

Is there any way to do this without this error>?

谢谢

推荐答案

为了能够从 Form 中删除控件,当由 ComboBox 触发时,您需要通过Timer来执行删除操作.

In order to be able to remove controls from a Form, when triggered by a ComboBox, you will need to execute the deletion operation through a Timer.

所以,当 ComboBox 事件被触发时,启动(启用)一个 Timer,当它被触发时,首先调用你想要调用的子程序.

So, when the ComboBox event is to be triggered, start (enable) a Timer that when triggered, calls the subroutine that you wanted to call in the first place.

代码如下:

Private Sub MyCombo_Change()
    MyTimer.Enabled = False
    MyTimer.Enabled = True
End Sub

Private Sub MyTimer_Timer()
    MyTimer.Enabled = False
    DeleteMenuItems
End Sub

Private Sub DeleteMenuItems()
    Dim i As Intener
    For i = mnuTCategory.Count - 1 To 1 Step -1
       Unload mnuTCategory(i)
    Next
End Sub

这篇关于从弹出菜单中卸载项目错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆