Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

Is it impossible to enumerate menus????

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zt - 02 Oct 2004 12:36 GMT
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
Sijin Joseph - 02 Oct 2004 13:20 GMT
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
Mick Doherty - 02 Oct 2004 13:50 GMT
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
Stoitcho Goutsev \(100\) [C# MVP] - 04 Oct 2004 14:18 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.