Menu items name

  • Thread starter Thread starter Sachin D.
  • Start date Start date
S

Sachin D.

In VB.net menus, there is a name property, but it isnt
available in runtime..strange!!!

does someone has a idea how i can do something similar?

reason i want it is...in my app the UI text comes from a
language table in database. For form and control text i
retrieve it using the formname+control name. But doing the
same thing for menu is not possible. One idea is to store
the name of the menu item e.g. mnuFile in the text itself
and at runtime change the text by using the original text
of the menuitem. Drawback is, at runtime i cannot get the
UI text twice as now the control has lost its name.

Regards

Sachin
 
Sachin D. said:
In VB.net menus, there is a name property, but it isnt
available in runtime..strange!!!

does someone has a idea how i can do something similar?

reason i want it is...in my app the UI text comes from a
language table in database. For form and control text i
retrieve it using the formname+control name. But doing the
same thing for menu is not possible. One idea is to store
the name of the menu item e.g. mnuFile in the text itself
and at runtime change the text by using the original text
of the menuitem. Drawback is, at runtime i cannot get the
UI text twice as now the control has lost its name.

<http://www.google.de/groups?as_q=author:herfried menuitem name&ie=UTF-8>
 
Yust a suggestion.
..net offers a different sollution for multilangual forms, localizable forms.
using the localizable and language properties. you might want to explore
that option 2.
 
Hi Sachin,

The code below might help you play with your menus - when you've explored
creating your own MenuItem class and looked into Localisation. ;-)

Regards,
Fergus

<code>
Public Module MenuStuff

Public Function GetMenuItems (F As Form) As ArrayList
Dim alMenuItems As New ArrayList
Dim oMainMenu As MainMenu = F.Menu

If oMainMenu Is Nothing OrElse _
oMainMenu.MenuItems Is Nothing Then _
Return alMenuItems

GetMenuItems (alMenuItems, oMainMenu.MenuItems)
Return alMenuItems
End Function

Private Sub GetMenuItems (alMenuItems As ArrayList, _
aoMenuItems As Menu.MenuItemCollection)
alMenuItems.AddRange (aoMenuItems)
Dim oMenuItem As MenuItem
For Each oMenuItem In aoMenuItems
GetMenuItems (alMenuItems, oMenuItem.MenuItems)
Next
End Sub
End Module

Sub DisplayMenus (F As Form)
Dim alMenuItems As ArrayList = GetMenuItems(F)
Dim oMenuItem As MenuItem
For Each oMenuItem In alMenuItems
Console.WriteLine (oMenuItem.Text)
Next
End Sub
</code>
 
Back
Top