How to disable child form controls?
I have a login which have admin and user rights.
If admin- i can access all the forms and controls. --OK
If user- i can only access limited forms and controls. I have Mdi parent and other forms.
--NOT OK
I can only dis开发者_高级运维able toolstrip menu on MDI parent but i need to disable controls on the other childforms also.
like butttons/textboxes etch..
There are many ways you can do this:
- When opening/loading the control, pass the login rights to the child control and have the OnLoad method set the visibility
- Add a public method on your child form to hide the control. The parent could then call this method
- Make the controls public and access them directly from the parent (i.e.
childForm.ControlToHide.Visible = false
). Gets the job done but is not recommended
Lots of other ways too, these are simply the "easy" ones.
精彩评论