If our Winform application is having Menu level security, we can build the Main menu using XML in following way.
Like ASP.Net Tree control, we can build the Main menu using XML in runtime. For that i have created three methods,
and one event.
Here the method CreateMenu is used to create all menu items by using CreateMenuItem and CreateMenuItems.
CreateMenuItem is used to create Top level menuitems and CreateMenuItems is used to create all child level menuitems.<?xml:namespace prefix = v /><v:shapetype coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> The following figure shown the XML file format.
CreateMenuItems is a recursive method, so you can include n-level menuitems.
The menu will be shown like,
And Menu_Click event is used to configure the all menu item events.
I think this shows how you can implement the security in MainMenu and any help, comments are much appreciated!