65.9K
CodeProject is changing. Read more.
Home

Dynamic MainMenu Formation in WinForm Application using DataSet

Feb 12, 2004

2 min read

viewsIcon

120686

downloadIcon

3007

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.

Dynamic MainMenu Formation in WinForm Application using DataSet - CodeProject