Hello guys, plz help.
I have a table with the data of my transactions (menu options) like
this
type: M : Menu S : Submenu P: Option (click to open a form)
id description type father
m_001 Menu 1 M NULL
m_002 SubMenu1 S m_001
m_003 Option P m_002
Obs: The forms that I've created have de menu_id in them Name, and Tag
Property.
Ok, with this style of table and organization I've created a dinamic
Menu in my MDI from in vb.net 2005. and it works right. The problem is
when I want to open a form giving a Click to the corresponding menu
option.
First: I need to have a collections of all the forms of my application
(opened and closed). Then in runtime when generating the dinamic menu,
add a Click event to every Option in the menu dinamically too, and
asign the form of my form collection to be opened when I do click
above any option of my menu.
Can someone help me..????
The problem is that this Sub only search in the OPENED forms, I need
to search in ALL forms....!!!
Private Sub BuscaFormTag(ByVal tag As String)
For Each f As Form In My.Application.OpenForms
If f.Name.Equals(tag) Then
f = New System.Windows.Forms.Form
f.Show()
End If
Next
End
Here's the code I use to generate the OPTIONS of my menu
' Genera las pantallas Tipo: P
For Each pant As DataRow In dt_pantallas.Rows
ReDim Preserve Pantallas(k)
If
pant("mn_padre").ToString().Equals(submenu("mn_codigo").ToString())
Then
Pantallas(k) = New
System.Windows.Forms.ToolStripMenuItem
With Pantallas(k)
.Name =
pant("mn_descripcion").ToString()
.Size = New System.Drawing.Size(152,
22)
.Text =
pant("mn_descripcion").ToString()
.Tag = pant("mn_codigo")
.ToolTipText = pant("mn_codigo")
End With
MenuVertical(i).DropDownDirection =
ToolStripDropDownDirection.Right
MenuVertical(i).DropDownItems.AddRange(New
System.Windows.Forms.ToolStripItem() {Pantallas(k)})
'Manejador de eventos para determinar la
transaccion que se abrira con el evento click del menu
'AddHandler MenuVertical(i).Click,
AddressOf BuscaFormTag
End If
....
Any help are welcome