Link to home
Start Free TrialLog in
Avatar of D B
D BFlag for United States of America

asked on

Enabling Menu Toolstrip Items

I have a toolstrip that, by default, has a number of items disabled. I have a database table that defines different functionalities that a user is allowed in the application. Upon starting my application, I am reading that table, based on the UserName and returns a collection of permissible actions.

I am trying to figure out how to iterate through the collection and enable the appropriate menu items. I was thinking of associating the Tag of the individual menu items with the role, and iterating through the menu items for a tag that matches the role, but that seems like a lot of overhead. There will be different paths on the toolstrip that will be affected by this (for example, items under Tools, and subitems under those items, items under Reports, etc.

Some suggestions from the experts? I could map to the toolstrip item name, but that makes the data in the database table seem cryptic.
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

After the login/password autentication I enable the toolstripitens that as special access. Normally I define in the database the access level like 9 = administrator; 1 = user ...

Then on the form load I enable the menuitens that I want.
Avatar of D B

ASKER

There would be too many permutations. Coding would be a nightmare. I have 5-6 top level menu items, sub items, sub-sub items, etc. One user might have access to only. As this grows, there could be 15 Items that could be enabled at startup, which means 1,307,674,368,000 permutations. It is a lot easier to just access a subset of those 15 items and enable the appropriate items.
What is your datatable structure. Do you have a field for every menuitem?

Goran
sorry, database table, bot datatable. :)

Goran
Hi have, in most of my applications, a special menu (hidden by default) for administration. Also for the supervisors I have disabled items that I enable in the start up (just some).

Do you have so many options ?
Avatar of D B

ASKER

>> Do you have so many options ?
Yes, because, for example, there will be some reports that are only accessible to certain users. The tools menu will be the same, as will the administration menu. There will be way too many permutations to assign 'roles'.

>> Do you have a field for every menuitem?
Not every one, but a lot of them. Currently 6, and the application is young. And that doesn't include any reports.

I am thinking of wrapping this in a SELECT statement, and depending on the value returned (CASE), find and enable the appropriate menuitem.
Is adding a boolean field for every object (MenuItem, Report, Page, etc.)  you want that user to see out of the question?  Then you can make one database call and assign the visible property equal to the boolean value of the field for that user.  For example, If I have a website with a menu with three items...(Users, Admin, Supervisors), then when a user logs in they may or may not be able to view links with the right permissions assigned.
ASKER CERTIFIED SOLUTION
Avatar of D B
D B
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
maybe you could shorten your code by doing next:

1) have all columns in database table have names like toolstripmenuitems do
1) get data in datatable
2) loop through all columns, get column name, and find menuitem with this column name
3) set visible for this item to column value

Goran
Avatar of D B

ASKER

Priest04: Did I miss something? That is what I said I did.
If you are referring to your last post, then I didn't see that one. If you want to use "per user" settings, thats the fastest it can be.

Goran
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator