Reproduced in this article: http://www.cnblogs.com/wuhuacong/archive/2011/05/08/2040620.html
At this point, the Rights Management module introduction has been completed, the following gives a call example demo program to everyone reference learning, as follows:
Http://files.cnblogs.com/wuhuacong/SecurityDemo.rar
Dictionary Component Module Invocation example of the previous file The demo program is also available for download as follows:
Http://files.cnblogs.com/wuhuacong/DictionaryDemo.rar
Comments on the 40 floor:
However, you can first post the code in the core control section of the permission:/// <summary> ///To set permissions on a component on a form/// </summary> /// <param name= "form" >the form in which the control resides</param> /// <param name= "Getpermissionshandler" >gets the key value pair of the component name and its Enabled property (current user) in the form</param> Public Static voidSetPermissions ( ThisForm form, Func<form, idictionary<string,BOOL>>Getpermissionshandler) {Type T=form. GetType (); Fieldinfo[] FS= T.getfields (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance |bindingflags.static); IDictionary<string,BOOL> Permissions =Getpermissionshandler (form); foreach(FieldInfo FinchFS) {Dynamic Component=f.getvalue (form); if(Component isSystem.ComponentModel.Component &&permissions. ContainsKey (F.name)) {Try{component. Enabled=Permissions[f.name]; } Catch { } } } }
Rights management System of WinForm development framework