Click here to Skip to main content
Click here to Skip to main content

Dynamic MainMenu formation in WinForm Application using DataSet

, 24 Feb 2004
Rate this:
Please Sign up or sign in to vote.
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 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 purpose, 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 purpose. So I didn't concern 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 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, 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

Share

About the Author

Amalorpavanathan Yagulasamy(AMAL)
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 PinprofessionalEmmanuel Medina Lopez16-Jul-13 9:39 
Questiondatabase driven menu PinmemberNamdev Karande23-Aug-12 0:06 
GeneralIn te right direction... Pinmembermalharone1-Aug-05 6:47 
Generalerror compiling solution PinmemberAntonio Barros11-Jul-04 5:34 
Hi
 
First of all, thank you for your good and usefull work.
When i compiled the solution (DynamicMenu) i've got the error
"C:\CodeProject\Dynamic MainMenu formation in WinForm Application using DataSet\DynamicMenuDataSet_src\DynamicMenuDataSet\Form1.cs(115): The name '_' does not exist in the class or namespace 'DynamicMenu.Form1'"
 

A.Barros

GeneralCool Pinmemberdevxon18-Feb-04 5:17 
GeneralRe: Cool PinmemberAmalorpavanathan Yagulasamy(AMAL)18-Feb-04 7:02 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 25 Feb 2004
Article Copyright 2004 by Amalorpavanathan Yagulasamy(AMAL)
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid