Effecting other controls on a form from withing a compiled control

Denaes

Senior Contributor
Joined
Jun 10, 2003
Messages
956
Effecting other controls on a form from within a compiled control

This is something I really want to learn more about.

Say I made a control and it does many nice things that are useful. One thing is to press the "Disable" button and disable (enable = False) every other control on a form. Now preferably I just want to drag this control onto a form and be able to click the button and everything is disabled.

I'm pretty sure I can do this easily. Just do a myBase.ControlCollection "for each control..." and make sure I'm not disabling the control doing this. This would work right?

Well where I want to take it is to be able to choose certain controls to subscribe to this controlcollection rather than just disable everything.

Primarily this is a control to help manage database front end functionality. When I do an "Edit", I want to disable all the navigation controls, but enable all of the databound controls.

part of the problem (why I'm not just doing a search for databound controls) is that other databound controls are the opposite (like some listboxes & comboboxes) and are used for navigation and should be disabled for Edit/add.

The optimal solution is a way to just drop the control and go. I don't think that'll happen. I think the best I'll get is exposing properties to add controls to specific collections and have (at least) two controlcollection: 1 to disable on Add/Edit and enable on View and another to enable on Add/Edit and disable on View.

If anyone has similar ideas that would work, I'm definately all ears. I would have just tested this all out, but I'm not able to get to VS for a while. I'll post when I do get some testing done.
 
Last edited:
Ok, I have a fast update.

The myBase thing didn't work at all. It went to the base of the customcontrol and disabled all controls on it. Duh, I should have guessed that. I'd have to pass in an instance of the form to get at it's ControlCollection...

But thats not what I'm ultimately going for anyways.

I created a collection in my control and a writeonly property that is of Control type. It adds it to the collection.

That works and I can then enable/disable those controls as I wish. It really just means that I have to associate which controls will be ruled by my control on form load.

I'll probobly also have quite a few properties/functions to get a list of controls in each collection (the name of each control is it's key) and ways to remove controls as well.

This looks like it's what I'm looking for. Of course if anyone has any advice, chime in :)
 
Back
Top