删除菜单项和子菜单项 [英] Removing Menu Items and Child Menu Items

查看:71
本文介绍了删除菜单项和子菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试有条件地删除2.0 .NET菜单项的菜单项

控制并且我很难过。


这删除了根级项目:


Menu1.Items.Remove(Menu1.FindItem(" Administration"))


但这不会删除它''子项目


Menu1.Items.Remove(Menu1.FindItem(" Administration / Activities)))


不会抛出任何错误,并且FindItem * IS *查找管理/

活动值路径。我正在使用正斜杠的默认值路径分隔符

,但菜单项仍然出现。


我做错了什么? Thx。

Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I''m stumped.

This removed a root level item:

Menu1.Items.Remove(Menu1.FindItem("Administration" ))

But this does not remove it''s child item

Menu1.Items.Remove(Menu1.FindItem("Administration/Activities"))

No errors are thrown, and FindItem *IS* finding Administration/
Activities value path. I''m using the default value path separator of
the forward slash, but the menu item still appears.

What am I doing wrong? Thx.

推荐答案

7月10日下午2:32,Larry Bud< larrybud2 ... @ yahoo.comwrote:
On Jul 10, 2:32 pm, Larry Bud <larrybud2...@yahoo.comwrote:

尝试有条件地删除2.0 .NET菜单项的菜单项

控制并且我很难过。


这删除了根级项:


Menu1.Items.Remove(Menu1.FindItem(" Administration"))


但这不会删除它的子项


Menu1.Items.Remove(Menu1.FindItem(" Administration / Activities)))


不抛出任何错误,FindItem * IS *查找Administration /

活动值路径。我正在使用正斜杠的默认值路径分隔符

,但菜单项仍然出现。


我做错了什么?谢谢。
Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I''m stumped.

This removed a root level item:

Menu1.Items.Remove(Menu1.FindItem("Administration" ))

But this does not remove it''s child item

Menu1.Items.Remove(Menu1.FindItem("Administration/Activities"))

No errors are thrown, and FindItem *IS* finding Administration/
Activities value path. I''m using the default value path separator of
the forward slash, but the menu item still appears.

What am I doing wrong? Thx.



多一点信息:

Menu1.FindItem(" Administration / Activities")。Enable = false


DOES禁用菜单项。那么为什么我不能删除它?

Just a little more info:
Menu1.FindItem("Administration/Activities").Enable=false

DOES disable the menu item. So why can''t I remove it?


嗨拉里,
Hi Larry,

试图有条件地删除2.0 .NET菜单项的菜单项

控制,我很难过。
Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I''m stumped.



你为什么要这样做?我想知道,因为可能比items.remove更聪明

方式。


Jeppe Jespersen

丹麦

Why do you want to do this? I''d like to know, as there might be a smarter
way than "items.remove".

Jeppe Jespersen
Denmark


>

这删除了根级别项目:


Menu1 .Items.Remove(Menu1.FindItem(" Administration"))


但这不会删除它的子项


Menu1.Items.Remove(Menu1.FindItem(" Administration / Activities)))

不会抛出任何错误,FindItem * IS *正在查找Administration /

活动价值路径。我正在使用正斜杠的默认值路径分隔符

,但菜单项仍然出现。


我做错了什么? Thx。
>
This removed a root level item:

Menu1.Items.Remove(Menu1.FindItem("Administration" ))

But this does not remove it''s child item

Menu1.Items.Remove(Menu1.FindItem("Administration/Activities"))

No errors are thrown, and FindItem *IS* finding Administration/
Activities value path. I''m using the default value path separator of
the forward slash, but the menu item still appears.

What am I doing wrong? Thx.



7月10日下午3:21,Jeppe Jespersen < jdj at jdj dot dkwrote:
On Jul 10, 3:21 pm, "Jeppe Jespersen" <jdj at jdj dot dkwrote:

嗨Larry,
Hi Larry,

试图有条件地删除菜单项2.0 .NET菜单项

控制,我很难过。
Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I''m stumped.



你为什么要这样做?我想知道,因为可能有比items.remove更聪明的方式
方式。


Why do you want to do this? I''d like to know, as there might be a smarter
way than "items.remove".



根据用户角色隐藏菜单项。


没有可见字样属性,启用标志只是简单的丑陋。

To hide menu items based on a User''s role.

There''s no "visible" property, and the Enable flag is just plain ugly.


这篇关于删除菜单项和子菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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