I need to translate program to another language.
How to enumerate all menus and submenus in form??
I have used for each loop in vb6 but how to di this in vb.net??
VB:
----------------------------------------------------------------------------
----
'i try this in vb.net
Private Function ListMenus(ByVal frm As Form) As String
Dim tstr As String
For Each ctrl As Control In frm.Controls
If TypeName(ctrl) ="Menu" Then
tstr &= ctrl.Name & vbCrLf
End If
Next
MsgBox(tstr)
End Sub
----------------------------------------------------------------------------
----
MenuItem does not have Tag proprty anymore???
It sounds very simple but...arggggggh.. How to do this?? ; )
-Sepu
You can check that the control is of type MenuItem instead of checking
if the TypeName is Menu, something like
If TypeOf control Is MenuItem Then
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> I need to translate program to another language.
>
[quoted text clipped - 21 lines]
>
> -Sepu
MenuItems are Components not Controls, so you won't find them in the forms
Controls Collection.
If you want a Tag property for standard MenuItems then use my MenuExtender,
the code for which you'll find at the following link:
http://dotnetrix.co.uk/menus.html
This MenuExtender also implements Radio Grouping.
To Enumerate Menus use the following code, which accesses the Tag property
of the MenuExtender.
\\\
Private Function ListMenuTags(ByVal frm As Form) As String
Return EnumerateMenuTags(frm.Menu)
End Function
Private Function EnumerateMenuTags(ByVal M As Menu) As String
Dim MenuTagCollection As String
For Each MI As MenuItem In M.MenuItems
Dim MenuTag As String = CType(MenuExtender1.GetTag(MI), String)
If Not MenuTag Is Nothing Then
MenuTagCollection += MenuTag & vbCrLf
End If
MenuTagCollection += EnumerateMenuTags(MI)
Next
Return MenuTagCollection
End Function
///

Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
>I need to translate program to another language.
>
[quoted text clipped - 21 lines]
>
> -Sepu
zt - 03 Oct 2004 07:35 GMT
I have now downloded the code for MenuExtender.
I have standard version of Visual Basic, so i can' compile code ton
component directly from vb.
Would You put compiled component to Your web site?
I try also to compile component from command line..
Thanks anyway!
-zt
zt - 03 Oct 2004 08:10 GMT
Hi!
Now i have compiled version of Your MenuExtender.
It is very fine!!
Thanks a L O T!
-zt
Hi zt,
First of all the MainMenu and menu items as well as context menues are not
controls, so looping through Control's collection won't give you anything.
Secondly, Checking for the controls and components Names is not a good ideia
since if they are dynamically created they migt have no names.
AFAIK there is no method that will work in all of the cases. If it is form
that you wrote yourself you need to add some special functionallity (expose
some methods) that will help you enumerate the menu items. Otherwise unlike
controls components don't have to reside in any collection.

Signature
HTH
Stoitcho Goutsev (100) [C# MVP]
>I need to translate program to another language.
>
[quoted text clipped - 21 lines]
>
> -Sepu
zt - 04 Oct 2004 16:08 GMT
> First of all the MainMenu and menu items as well as context menues are not
> controls, so looping through Control's collection won't give you anything.
> Secondly, Checking for the controls and components Names is not a good ideia
> since if they are dynamically created they migt have no names.
If i create dynamicaly something i name it too...
> AFAIK there is no method that will work in all of the cases. If it is form
> that you wrote yourself you need to add some special functionallity (expose
> some methods) that will help you enumerate the menu items. Otherwise unlike
> controls components don't have to reside in any collection.
I have use now Mick Doherty:s MenuExtender, it is very good solution for
this. : ))
-zt