MenuItem Name属性 [英] MenuItem Name property

查看:107
本文介绍了MenuItem Name属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我能够获得一个MenuItem对象的Name属性@

设计时间,但是我无法获得相同的@ run-

时间......为什么?


由于MenuItem不会从Control类继承,

它甚至不应该可用@设计时间

对吧?


提前谢谢

Rakesh

解决方案

Rakesh,


设计师通过实际扩展您的

类,然后在属性网格中托管它。然后,Name属性

揭示该派生类。 Name属性实际上是

变量的名称,您应该知道它。如果你不是,那么你将需要

在MenuItem上放置某种类型的标识符(通过扩展

MenuItem类并附上你的信息)。 br />

你想做什么?

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


"勒凯什" <一个******* @ discussions.microsoft.com>在消息中写道

news:0b **************************** @ phx.gbl ... < blockquote class =post_quotes>

我能够获得一个MenuItem对象的Name属性@
设计时间,但是我无法获得相同的@ run-
时间......为什么?

由于MenuItem并没有从Control类继承,
它甚至不应该可用@ design-time
对吗?

提前致谢
Rakesh



我有同样的问题


我正在尝试构建一个MDI模板,其他开发人员可以在以后自定义。

我想在mainform上包含代码,这些代码将启用或禁用稍后仅添加名称的menuitems。该函数将从子表单调用。这些菜单项在设计时不存在于模板中

我有使用text属性的代码,但这不允许使用常用名称。例如。 File / new和Window / new都会同时被禁用或启用。


听起来我有类似的问题


我正在研究MDI模板,我想在mainform上放置代码来启用或禁用menuitems。


第一个问题是我必须处理不存在的菜单项我在设计模板时,可以在以后由其他开发人员添加。我不想公开菜单项并打开现有项目来篡改


禁用项目的触发器将来自一个不知道menuitem对象和必须传递一个字符串来识别一个项目


我有使用Text属性工作的代码,但它不允许使用常见的项目名称。例如它认为File / new和Window / new是相同的东西


第二个问题是处理菜单选择。如果要处理菜单,请单击子窗体并且无法将其传递给对象,如何识别菜单项?记住有问题的项目被添加到派生形式而不是原始模板

----- Nicholas Paldino [.NET / C#MVP]写道:----


Rakesh


设计师通过实际扩展你的物品来完成名称属性

类,然后在属性网格中托管它。 Name属性是

公开该派生类。 Name属性实际上是

变量的名称,您应该知道它。如果你不是,那么你将需要在菜单上放置某种类型的标识符(通过扩展
MenuItem类并附上你的信息)

/>

你想做什么

-

- Nicholas Paldino [.NET / C#MVP

- mv*@spam.guard.caspershouse.co

" Rakesh" ; <一个******* @ discussions.microsoft.com>在消息中写道

新闻:0b **************************** @ phx.gbl ..

您好

我能够获得一个MenuItem对象的Name属性


设计时间,但是我无法获得相同的@ run
时间......为什么

并且因为MenuItem没有继承自Control类


它甚至不应该可用@ design-tim

感谢advanc


Rakes



Hi,

I am able to obtain a MenuItem object''s Name property @
design-time, but am not able to get the same @ run-
time...why?

And since MenuItem doesn''t inherit from Control class,
it''s not even supposed to be available @ design-time
right?

Thanks in advance
Rakesh

解决方案

Rakesh,

The designer accomplishes the name property by actually extending your
class and then hosting that in the property grid. The Name property is then
expose off that derived class. The Name property is really the name of the
variable, which you should know already. If you don''t, then you will need
to place the identifier of some sort on the MenuItem (by extending the
MenuItem class and attaching your information).

What are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rakesh" <an*******@discussions.microsoft.com> wrote in message
news:0b****************************@phx.gbl...

Hi,

I am able to obtain a MenuItem object''s Name property @
design-time, but am not able to get the same @ run-
time...why?

And since MenuItem doesn''t inherit from Control class,
it''s not even supposed to be available @ design-time
right?

Thanks in advance
Rakesh



I have the same problem

I am trying to build an MDI template other developers can customize later.
I want to include code on the mainform that will enable or disable menuitems added later given only their names. the function will be called from a child form. These menuitems do not exist at design time for the template
I have code that works using the text property but this does not allow for common names. E.g. File/new and Window/new both get disabled or enabled at the same time.


It sounds like I have a similar problem

I am working on an MDI template and I want to place code on the mainform to enable or disable menuitems.

The first problem is I must cope with menu items that do not exist while I am designing the template, they can be added later by another developer. I do not want to make the menu items public and open the existing items to tampering

The trigger to disable an item will originate from a child form which will not know about the menuitem objects and must pass a string to identify an item

I have code that works using the Text property but it won''t allow for common item names. e.g. it thinks File/new and Window/new are the same thing

the second problem is processing the menu selections. If you want to process the menu click on the child form and cannot pass it an object, how do you identify the menu item? Remembering that the item in question was added to a derived form not the original template
----- Nicholas Paldino [.NET/C# MVP] wrote: ----

Rakesh

The designer accomplishes the name property by actually extending you
class and then hosting that in the property grid. The Name property is the
expose off that derived class. The Name property is really the name of th
variable, which you should know already. If you don''t, then you will nee
to place the identifier of some sort on the MenuItem (by extending th
MenuItem class and attaching your information)

What are you trying to do
--
- Nicholas Paldino [.NET/C# MVP
- mv*@spam.guard.caspershouse.co

"Rakesh" <an*******@discussions.microsoft.com> wrote in messag
news:0b****************************@phx.gbl..

Hi

I am able to obtain a MenuItem object''s Name property


design-time, but am not able to get the same @ run
time...why

And since MenuItem doesn''t inherit from Control class


it''s not even supposed to be available @ design-tim
right

Thanks in advanc


Rakes



这篇关于MenuItem Name属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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