0

I want to handle user authorization access to every form and control in my project, I did it manually in my previous projects using many checkboxes and writing many lines of codes, but now I want to handle it automatically, so I loop through each form to get its controls (and components Devexpress) and save them in TreeNode, after this, I saved checked state of each node/child node in a 2D array of strings that contain form name, control name, checked status, now in startup I formed the code that can be evaluated and executed in runtime to enable or disable the control for example:

"FRM_NAME.ControlName.enabled = false;"

enter image description here

I see some topics about executing codes in runtime but I was blocked in many situations, for example, Roslyn is not supporting .net framework 4.5.2 (my current version) I tried other libraries but they execute a separate code that is not related to my project.

I have 02 questions:

1- What is the best way to handle user authorization access looping through all controls automatically?

2- How to evaluate code formed as a string like:

Evaluate("FORMNAME.CONTROLNAME.Enabled = false;");

  • If you already have a collection of control names, why not just loop through the collection, use the [Control.ControlCollection.Find method](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.find%28VS.80%29.aspx) to get the instance of each and set its Enabled property accordingly? – Brendon Dec 22 '21 at 14:35

0 Answers0