Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
Dim cm As ContextMenu
cm.Initialize("cm")
For i = 1 To 10
Dim mi As MenuItem
mi.Initialize("Item #" & i, "mi")
cm.MenuItems.Add(mi)
Next
Button1.ContextMenu = cm
End Sub
Sub mi_Action
Dim mi As MenuItem = Sender
Log(mi.Text)
End Sub