|
-
Jul 8th, 2010, 02:27 AM
#1
[RESOLVED] Making a Component "one per Form"
I'm making a custom Toolbox Component which I want to restrict to one instance per form. It's a non-visual component like a Timer, not a control. I am able to enforce the restriction at design time by checking if the Container.Components list already contains a component of the same type.
But I want to do something similar when someone adds an instance of the component in code. It's easy in the case of a Control because you can check in Form.Controls. Unfortunately the Controls list doesn't contain non-visual components.
Does anyone know a way of getting a list of a form's non-visual components? They are obviously present in the form's designer.vb file, but I don't know how to access that in code. Or can someone suggest another way to restrict the component to one per form?
Note that I don't want to place special requirements on the form itself. For example, I considered using the Form's Tag property to set a flag if it already contains an instance of the component. But that precludes using the Tag for some other purpose.
BB
Last edited by boops boops; Jul 8th, 2010 at 02:33 AM.
Reason: always a typo!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|