1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| Dim Menu_Strip As MenuStrip
Menu_Strip = New MenuStrip()
Me.Controls.Add(Menu_Strip)
Dim RacineMenu As New ToolStripMenuItemCoposant("Racine1")
' Création de l'objet XMLDocument
Dim XmlDoc As New Xml.XmlDocument
Try
XmlDoc.Load("c:\fichier.XML")
Catch ex As Exception
MsgBox("Impossibilité de charger le fichier XML")
End Try
'Réinitialisation du menu strip
Menu_Strip.Items.Clear()
' Création de la collection nuds INFOS
Dim element As Xml.XmlNodeList = XmlDoc.SelectNodes("//infos")
' Création des variables de noeud unique
Dim noeud As Xml.XmlNode
Dim noeudEnf As Xml.XmlNode
Dim _NomRaccourci, _Chemin As String
' Pour tous les noeuds de la collection INFOS
' et Pour tous les noeuds enfants du noeud
' On recupere le champs Nom_Raccourci
' Si on trouve le noeud "Nom_Raccourci"
' On récupère son texte qu'on instancie à la variable _NomRaccourci
' Et on l'affiche dans le MenuStrip
For Each noeud In element
For Each noeudEnf In noeud.ChildNodes
If noeudEnf.LocalName = "Nom_Raccourci" Then
_NomRaccourci = noeudEnf.InnerText
ElseIf noeudEnf.LocalName = "Chemin" Then
' Je récupère bien le chemin du nom_raccourci
_Chemin = noeudEnf.InnerText
End If
Next
'Instantiation du composant à base du chemin et du nom du raccourci et l'imge puis le handler
Dim NewMenu As New ToolStripMenuItemCoposant(_Chemin, _NomRaccourci, Nothing, New EventHandler(AddressOf windowNewMenu_Click))
RacineMenu.add(NewMenu)
CType(RacineMenu.DropDown, ToolStripDropDownMenu).ShowImageMargin = False
CType(RacineMenu.DropDown, ToolStripDropDownMenu).ShowCheckMargin = True
Next
Menu_Strip.MdiWindowListItem = RacineMenu
' Add the window ToolStripMenuItem to the MenuStrip.
Menu_Strip.Items.Add(RacineMenu)
' Dock the MenuStrip to the top of the form.
Menu_Strip.Dock = DockStyle.Top
' The Form.MainMenuStrip property determines the merge target.
Me.MainMenuStrip = Menu_Strip |
Partager