|
-
May 14th, 2013, 11:28 AM
#1
Thread Starter
New Member
Adding a through controls.add?
This is what I'm doing:
Code:
Dim count As New Timer
controls.add(count)
Is there an alternative to this? as VB doesn't seem to like it.
-
May 14th, 2013, 11:34 AM
#2
Re: Adding a through controls.add?
Look at your question. Do we know what controls is or should we assume something? "VB doesn't seem to like it" doesn't mean much.
What are you trying to accomplish?
-
May 14th, 2013, 11:36 AM
#3
Re: Adding a through controls.add?
VB doesn't like it at all. Timer is not a control!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 14th, 2013, 11:40 AM
#4
Re: Adding a through controls.add?
A timer is a component rather than a control, and the Controls collection can only accept Controls or things derived from Control. Fortunately, this doesn't matter, as there is no good reason to add a timer to a Controls collection. A timer is not contained within anything, but is just a member variable in the form class itself. Since it has no location, or any of the other features of a control, you wouldn't gain in any way by adding it to a collection.
My usual boring signature: Nothing
 
-
May 14th, 2013, 11:55 AM
#5
Thread Starter
New Member
Re: Adding a through controls.add?
 Originally Posted by Shaggy Hiker
A timer is a component rather than a control, and the Controls collection can only accept Controls or things derived from Control. Fortunately, this doesn't matter, as there is no good reason to add a timer to a Controls collection. A timer is not contained within anything, but is just a member variable in the form class itself. Since it has no location, or any of the other features of a control, you wouldn't gain in any way by adding it to a collection.
Ah, I get it... what was I thinking. Very obvious really.
-
May 14th, 2013, 12:16 PM
#6
Re: Adding a through controls.add?
Frankly, I've made that mistake, as well. Something on the toolbar, such as a timer and all controls, gets dragged onto the form. In that way, you are interacting with all of them in a similar fashion, so it is fairly automatic to assume that they are all the same animal in some way.
My usual boring signature: Nothing
 
-
May 14th, 2013, 03:36 PM
#7
Re: Adding a through controls.add?
The designer tricks you into believing that a parent/child relationship exists between a Form and a Component like a Timer. Only controls have a true relationship via the Form's control collection but with Timers and such, the designer adds it to an IContainer implementation which is referenced by nothing more than a private field generated by the designer. Any class that implements IComponent and has a public constructor that takes an IContainer will be added to the IContainer implementation referenced by the designer generated private field of the Form.
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
|