By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,482 Members | 1,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,482 IT Pros & Developers. It's quick & easy.

menuitem is an object ??

P: n/a
dim c as controls
for each c in me.controls
messagebox.show(c.name)
next c

I found that the menu time didn't show up ?? It didn't belongs to the
control in the form ???
I need to Me.mnuXXX.Enabled = false during run-time
Anyone know how can do that ??
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You do something like:
For each Item As MenuItem in Me.Menu.MenuItemCollection
If <condition> Then
Item.Enabled = False
End If
Next Item

hope this helps..
Imran.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
dim c as controls
for each c in me.controls
messagebox.show(c.name)
next c

I found that the menu time didn't show up ?? It didn't belongs to the
control in the form ???
I need to Me.mnuXXX.Enabled = false during run-time
Anyone know how can do that ??

Nov 21 '05 #2

P: n/a
Agnes,
As Imran suggests.

MenuItem is an object, however it is NOT a control.

Your form has both a Menu property that is the main menu, and a ContextMenu
(inherited from Control) that is used for context menus.

You need to use the MenuItems collection of the respective menu.
I need to Me.mnuXXX.Enabled = false during run-time
Anyone know how can do that ??
Have you tried?

Me.mnuXXX.Enabled = False

Or are you wanting to dynamically set a menu.Enabled to false based on a
string? Remember MenuItems don't have names exposed at runtime (they are
compile time only).

Hope this helps
Jay
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl... dim c as controls
for each c in me.controls
messagebox.show(c.name)
next c

I found that the menu time didn't show up ?? It didn't belongs to the
control in the form ???
I need to Me.mnuXXX.Enabled = false during run-time
Anyone know how can do that ??

Nov 21 '05 #3

P: n/a
* "Imran Koradia" <no****@microsoft.com> scripsit:
For each Item As MenuItem in Me.Menu.MenuItemCollection


'...in Me.Menu.MenuItems'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4

P: n/a
oops..sorry. Thanks for pointing that out, Herfried :)

Imran.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2p************@uni-berlin.de...
* "Imran Koradia" <no****@microsoft.com> scripsit:
For each Item As MenuItem in Me.Menu.MenuItemCollection


'...in Me.Menu.MenuItems'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

P: n/a
Thanks for all reply.
Menuitems don't have a name at runtime?! My god. It is a must that I need to
disable some menuitem during run-time. My approach is "My application got
one menu bar , every user got its security tables, he/she got different
permission in each forms. e.g Invoicing , user A allows to use invoice, but
not user B'

As userB Login the application, i need to disable the 'Invoice menu' .
HOWEVER, I can't use the menuitem.text becauese the menu item will be
displayed in GB or B5, or English.
May be I need to change my security design....
From AGnes

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> 在郵件
news:ev*************@TK2MSFTNGP12.phx.gbl 中撰寫...
Agnes,
As Imran suggests.

MenuItem is an object, however it is NOT a control.

Your form has both a Menu property that is the main menu, and a ContextMenu (inherited from Control) that is used for context menus.

You need to use the MenuItems collection of the respective menu.
I need to Me.mnuXXX.Enabled = false during run-time
Anyone know how can do that ??


Have you tried?

Me.mnuXXX.Enabled = False

Or are you wanting to dynamically set a menu.Enabled to false based on a
string? Remember MenuItems don't have names exposed at runtime (they are
compile time only).

Hope this helps
Jay
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
dim c as controls
for each c in me.controls
messagebox.show(c.name)
next c

I found that the menu time didn't show up ?? It didn't belongs to the
control in the form ???
I need to Me.mnuXXX.Enabled = false during run-time
Anyone know how can do that ??


Nov 21 '05 #6

P: n/a
As suggested in other posts use a HashTable. You can use the MenuTagger code
on my site to give a Tag property to all menuitems, but to be honest, it's
just as easy to use a HashTable directly.
http://dotnetrix.co.uk/menus.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl...
Thanks for all reply.
Menuitems don't have a name at runtime?! My god. It is a must that I need
to
disable some menuitem during run-time. My approach is "My application got
one menu bar , every user got its security tables, he/she got different
permission in each forms. e.g Invoicing , user A allows to use invoice,
but
not user B'

As userB Login the application, i need to disable the 'Invoice menu' .
HOWEVER, I can't use the menuitem.text becauese the menu item will be
displayed in GB or B5, or English.
May be I need to change my security design....
From AGnes

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> 在郵件
news:ev*************@TK2MSFTNGP12.phx.gbl 中撰寫...
Agnes,
As Imran suggests.

MenuItem is an object, however it is NOT a control.

Your form has both a Menu property that is the main menu, and a

ContextMenu
(inherited from Control) that is used for context menus.

You need to use the MenuItems collection of the respective menu.
> I need to Me.mnuXXX.Enabled = false during run-time
> Anyone know how can do that ??


Have you tried?

Me.mnuXXX.Enabled = False

Or are you wanting to dynamically set a menu.Enabled to false based on a
string? Remember MenuItems don't have names exposed at runtime (they are
compile time only).

Hope this helps
Jay
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
> dim c as controls
> for each c in me.controls
> messagebox.show(c.name)
> next c
>
> I found that the menu time didn't show up ?? It didn't belongs to the
> control in the form ???
> I need to Me.mnuXXX.Enabled = false during run-time
> Anyone know how can do that ??
>
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.