我这样定,但运行不了,望高手指教:
Dim i As New MenuItem
For Each i In MainMenu1.MenuItems
i.Enabled = True
Next
7 个解决方案
#1
for(int i=0;i<MainMenu1.MenuItems.Count;i++)
{
MainMenu1.MenuItems[i].Enabled=True;
}
{
MainMenu1.MenuItems[i].Enabled=True;
}
#2
try:
Dim i As MenuItem '不需要new
For Each i In MainMenu1.MenuItems
i.Enabled = True
dim m as menuitem
for each m in i.menuitems
m.enabled=true
next
Next
如果你的子菜单只有一层,用上面的可以遍历所有的菜单项,如果层次不确定,就要写一个递归函数来调用!
Dim i As MenuItem '不需要new
For Each i In MainMenu1.MenuItems
i.Enabled = True
dim m as menuitem
for each m in i.menuitems
m.enabled=true
next
Next
如果你的子菜单只有一层,用上面的可以遍历所有的菜单项,如果层次不确定,就要写一个递归函数来调用!
#3
Dim i As MenuItem (不要用NEW)
For Each i In MainMenu1.MenuItems
i.Enabled = True
Next
For Each i In MainMenu1.MenuItems
i.Enabled = True
Next
#4
你的遍历只是遍历了第0层,也就是Enable的是你看见的像"文件","编辑"这个层次
#5
哦,没看比赛吗
#6
看着
昨晚看到四点
昨晚看到四点
#7
我是用下面的代码实现递归调用,但是不成功:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As MenuItem
For Each i In MainMenu1.MenuItems
If i.IsParent Then SetValue(False, i)
Next
End Sub
Private Function SetValue(ByVal Value As Boolean, ByVal M As MenuItem) As Boolean
Dim ii As MenuItem
For Each ii In M.MenuItems
ii.Enabled = Value
If ii.IsParent Then SetValue(Value, M)
Next
End Function
提示“未处理的“System.*Exception”类型的异常出现在 system.windows.forms.dll 中”。
请问各位是应该怎么改呢?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As MenuItem
For Each i In MainMenu1.MenuItems
If i.IsParent Then SetValue(False, i)
Next
End Sub
Private Function SetValue(ByVal Value As Boolean, ByVal M As MenuItem) As Boolean
Dim ii As MenuItem
For Each ii In M.MenuItems
ii.Enabled = Value
If ii.IsParent Then SetValue(Value, M)
Next
End Function
提示“未处理的“System.*Exception”类型的异常出现在 system.windows.forms.dll 中”。
请问各位是应该怎么改呢?
#1
for(int i=0;i<MainMenu1.MenuItems.Count;i++)
{
MainMenu1.MenuItems[i].Enabled=True;
}
{
MainMenu1.MenuItems[i].Enabled=True;
}
#2
try:
Dim i As MenuItem '不需要new
For Each i In MainMenu1.MenuItems
i.Enabled = True
dim m as menuitem
for each m in i.menuitems
m.enabled=true
next
Next
如果你的子菜单只有一层,用上面的可以遍历所有的菜单项,如果层次不确定,就要写一个递归函数来调用!
Dim i As MenuItem '不需要new
For Each i In MainMenu1.MenuItems
i.Enabled = True
dim m as menuitem
for each m in i.menuitems
m.enabled=true
next
Next
如果你的子菜单只有一层,用上面的可以遍历所有的菜单项,如果层次不确定,就要写一个递归函数来调用!
#3
Dim i As MenuItem (不要用NEW)
For Each i In MainMenu1.MenuItems
i.Enabled = True
Next
For Each i In MainMenu1.MenuItems
i.Enabled = True
Next
#4
你的遍历只是遍历了第0层,也就是Enable的是你看见的像"文件","编辑"这个层次
#5
哦,没看比赛吗
#6
看着
昨晚看到四点
昨晚看到四点
#7
我是用下面的代码实现递归调用,但是不成功:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As MenuItem
For Each i In MainMenu1.MenuItems
If i.IsParent Then SetValue(False, i)
Next
End Sub
Private Function SetValue(ByVal Value As Boolean, ByVal M As MenuItem) As Boolean
Dim ii As MenuItem
For Each ii In M.MenuItems
ii.Enabled = Value
If ii.IsParent Then SetValue(Value, M)
Next
End Function
提示“未处理的“System.*Exception”类型的异常出现在 system.windows.forms.dll 中”。
请问各位是应该怎么改呢?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As MenuItem
For Each i In MainMenu1.MenuItems
If i.IsParent Then SetValue(False, i)
Next
End Sub
Private Function SetValue(ByVal Value As Boolean, ByVal M As MenuItem) As Boolean
Dim ii As MenuItem
For Each ii In M.MenuItems
ii.Enabled = Value
If ii.IsParent Then SetValue(Value, M)
Next
End Function
提示“未处理的“System.*Exception”类型的异常出现在 system.windows.forms.dll 中”。
请问各位是应该怎么改呢?