Quote:
I'm trying to decentralize my application follow the function of the user logged in.So, I need to list all the controls (such as: Button, TextBox, ...) in the forms that the user can do action.
Honestly, I can't even envision how you are going to go about taking a list of all the forms and all the control names, and make that relate to user privileges when they log in. It seems that if everything is tied to the form names and control names then it will be hard to manage. Every time you add a control, or change a name then you have to rework your permissions code. I'd love to see how you go about accomplishing this based on form and control names.
I go a much different route: A "Priveleges" class. When a user logs in their Priveleges class is populated. The class contains booleans like "AllowEdit", "AllowMakeUsers", "AllowExit", "ShowTools", "AllowCustomize" and so on. Then the code of all the other forms just gets the user's Priveleges class to see if they are allowed to do something. If the user tries to open the 'Preferences' but "AllowCustomize" is false, then they get a dialog saying they don't have permissions.
In some places I just use the Priveleges to determine if certain menu options are even visible
EditMenu.Visible = AllowEdit;
Anyway, getting back to the way you want to do requiring getting all the form names and control names... I've never played with doing that. I'll play around with the code you provided and see what I can come up with.