Click here to Skip to main content
15,867,141 members
Articles / Programming Languages / XML

Dynamic MainMenu Formation in WinForm Application using DataSet

Rate me:
Please Sign up or sign in to vote.
3.94/5 (14 votes)
24 Feb 20042 min read 119.4K   3K   65   6
Dynamic MainMenu formation in WinForm application using DataSet

Sample Image - DynamicMenuDataSet.jpg

Table Of Contents

Introduction

This article demonstrates, how to form the Main menu through database based on a given login user. Here, I have given the table model and menu formation method. As in the previous article, which discussed XML driven menus generated at runtime, this article focuses on building menu through DataSet.

For demo purposes, I have created the DataSet in runtime.

Menu Level Security

We can give the permission to user for a particular screen or action through menu, when an application is loading itself. Like what are all the menus available to the user.

Flow for Menu level Security

The following figure shows the flow of this type of security model.

Flow

Table Design

See the table design below, I have added one column USERID. I have designed this table for demo purposes. So I am not concerned about normalization. You can design your table model, but SQL query output should be like MenuID, MenuName, MenuParent, Enable and USERID format.

Table

Login Form

See the Login Form below, you can select a user from here.

Login

Menu Design

The menu will be shown like for USERID='DEMO':

DEMO

for USERID='AMAL':

AMAL

Recursive Method

A recursive method CreateMenuItems has been used to create all the menu items. I have changed the CreateMenuItems a little bit to use a DataSet.

Code

Conclusion

I think this shows how you can implement the security in MainMenu through database and any help and/or comments are much appreciated!

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.


Written By
Web Developer
United States United States
Amalorpavanathan Yagulasamy (AMAL) is a Software Engineer for Protech Solution Inc. and has designed and implemented projects for Arkansas Child Support, Arkansas Budgetting, Michigan Child Support , Massachusetts Child Support, National Informatics Center-India and Indian Oil Corporation. His background is in developing relational databases and n-tier applications on Windows platforms in CMM Level Standards. He can be reached at amal_forum@hotmail.com

Comments and Discussions

 
SuggestionModify DB Design Pin
Emmanuel Medina16-Jul-13 9:39
professionalEmmanuel Medina16-Jul-13 9:39 
Questiondatabase driven menu Pin
Namdev Karande,23-Aug-12 0:06
Namdev Karande,23-Aug-12 0:06 
GeneralIn te right direction... Pin
malharone1-Aug-05 6:47
malharone1-Aug-05 6:47 
Generalerror compiling solution Pin
Antonio Barros11-Jul-04 5:34
professionalAntonio Barros11-Jul-04 5:34 
GeneralCool Pin
devxon18-Feb-04 5:17
devxon18-Feb-04 5:17 
GeneralRe: Cool Pin
Amalorpavanathan Yagulasamy(AMAL)18-Feb-04 7:02
Amalorpavanathan Yagulasamy(AMAL)18-Feb-04 7:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.