Dynamic MainMenu formation in Winform Application using XML






2.82/5 (11 votes)
Jan 28, 2004

59762

1738
Dynamic MainMenu formation in Winform Application using XML
Introduction
If our Winform application is having Menu level security, we can build the Main menu using XML in following way.
Building Menu
Like ASP.Net Tree control, we can build the Main menu using XML in runtime. For that i have created three methods,
CreateMenu
CreateMenuItem
CreateMenuItems
and one event.
Menu_Click
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.
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.
Finally
I think this shows how you can implement the security in MainMenu and any help, comments are much appreciated!