Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a login window and mainwindow based on the role of login user want to visible only particular control in mainwindow.These rights distribution data coming from database.

I have done this approach, once i login based on the role mentioned fetching data and for each tabitem and tabitem's controls(options like add, delete,edit,print) in mainwindow checking with the database data and making control visible and collapsed, means am hard coding the control names and checking with database data.Suppose in future i want to added some more tabitem or control to it,i need to change the code i have written for this right distribution method.Because i have 5 main tabitems inside each tabitem i have 8 more tabitems and control in it.

Could you please let me know the best approach or process i should follow it to achieve this scenario instead of hard coding it.
Posted

1 solution

There are a number of ways to achieve this - the way you have gone about it being one - unless you are likely to add more controls on a regular basis, you could stick with the current method.

Another option would be to tag each control with a value (say 10, 20, 30 etc), and have your user roles have a security value assigned to them (say 10 for read only, 20 for edit, 30 for admin etc), then simply have your code step through the controls, check the tag and show/hide the control (disable/enable, whatever you want to do) based on whether the user has permissions equal to or greater than the tag in the control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900