Click here to Skip to main content
14,930,311 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've got a class setup that creates textboxes dynamically as information is received.

I've got the handling events and everything set to it, but I want to set a private variable for each new instance of the textboxes to hold a time value, but I'm not sure where I would set it?

What I want to happen is when the timer counts down to 0 on the instance of the textbox, the foreground/background changes colour

Could someone just correct me on the concept of how it should work?

I believe the variable - lets call it minutes, should be placed within the create textbox class. When this class is activated it sets the time within its minutes variable.

When the timer_tick event runs, it takes away a count of 1 from the minutes variable.

I know I can't use a public shared variable, as whenever a new textbox is created, it would then re-write the minutes variable. All instances would use the same variable, which isn't correct. Each separate textbox should have it's own minutes set to it.
Posted
Comments
CHill60 5-Mar-14 19:00pm
   
Could use the Tag property?
   
First of all, when you say "TextBox", the question is: which one? Full type name, please.
The problem itself looks quite simple though. Find the closest common context of this data and put both controls and related data there.
—SA

1 solution

Yes you would use the tag property on the textbox.

Tag your countdown time to the window on creation
On your WM_Timer message use the time in the tag
Each textbox will have a different time local to creation time of the control

A reasonable article on the background on it's use in VB

http://www.coderslexicon.com/stash-data-away-in-controls-with-the-tag-property/[^]

If you want a deeper understanding VB is simply attaching properties to the window handle and you can pick up the concept from the standard windows API calls

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633561%28v=vs.85%29.aspx[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900