aniston
asked on
Creating Controls during Runtime possible?
What i want to do is create and slap NEW controls onto my blank form once my app runs. The reason i want to do this is beceause the new controls that are added to the form may repeat, meaning i want it to now alter to become control arrays. I have no idea how to do this. I am use to just slapping controls onto my form and going but since i want an indeterminite # of repeated instances of these controls i dont have a clue how to begin to do this.
Would it be wise to have the controls already on my form, but all having theire "visible" method set to "FALSE" and then somehow create instances of these controls and then display them? If this is the case please let me know how to do this.
Would it be wise to have the controls already on my form, but all having theire "visible" method set to "FALSE" and then somehow create instances of these controls and then display them? If this is the case please let me know how to do this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ljaques,
Your only asking for 1
NumTasks = NumTasks + 1
or 0=0+1=1
for 0 (already loaded) to 6 more use something like this...
Dim NumTasks As Integer
NumTasks = 1
Do Until NumTasks = 6
Load TaskFrame(NumTasks)
TaskFrame(NumTasks).Captio n = "Task " & NumTasks
TaskFrame(NumTasks).Top = (60 + ((NumTasks - 1) * 1140))
TaskFrame(NumTasks).Left = 45
TaskFrame(NumTasks).Width = 2475
TaskFrame(NumTasks).Height = 1065
TaskFrame(NumTasks).Visibl e = True
NumTasks = NumTasks + 1
Loop
Your only asking for 1
NumTasks = NumTasks + 1
or 0=0+1=1
for 0 (already loaded) to 6 more use something like this...
Dim NumTasks As Integer
NumTasks = 1
Do Until NumTasks = 6
Load TaskFrame(NumTasks)
TaskFrame(NumTasks).Captio
TaskFrame(NumTasks).Top = (60 + ((NumTasks - 1) * 1140))
TaskFrame(NumTasks).Left = 45
TaskFrame(NumTasks).Width = 2475
TaskFrame(NumTasks).Height
TaskFrame(NumTasks).Visibl
NumTasks = NumTasks + 1
Loop
Sorry i forgot to include the loop as you mentioned just above.
My code does look like what you just gave however it only visually displays the TaskFrame and not the other controls that may be inside that loop as well (ie. a Label). Must i use a: Show TaskFrame(numtasks), Show Label1(NumTasks),etc?
My code does look like what you just gave however it only visually displays the TaskFrame and not the other controls that may be inside that loop as well (ie. a Label). Must i use a: Show TaskFrame(numtasks), Show Label1(NumTasks),etc?
ljaques,
To set container use Set like this, I tried and it worked for me.
Load SiteNameLabel(NumTasks)
Set SiteNameLabel(NumTasks).Co ntainer = TaskFrame(NumTasks)
SiteNameLabel(NumTasks).Au toSize = True
SiteNameLabel(NumTasks).Fo nt.Name = "MS Serif"
SiteNameLabel(NumTasks).Fo nt.Size = 6
SiteNameLabel(NumTasks).Fo reColor = &H800080
SiteNameLabel(NumTasks).Ca ption = "---"
SiteNameLabel(NumTasks).Le ft = 1158 ''5
SiteNameLabel(NumTasks).To p = 122 '5
SiteNameLabel(NumTasks).Vi sible = True
To set container use Set like this, I tried and it worked for me.
Load SiteNameLabel(NumTasks)
Set SiteNameLabel(NumTasks).Co
SiteNameLabel(NumTasks).Au
SiteNameLabel(NumTasks).Fo
SiteNameLabel(NumTasks).Fo
SiteNameLabel(NumTasks).Fo
SiteNameLabel(NumTasks).Ca
SiteNameLabel(NumTasks).Le
SiteNameLabel(NumTasks).To
SiteNameLabel(NumTasks).Vi
ASKER
Thanks very much jbil...You are a genius!!
I said:
NumTasks = NumTasks + 1
Load TaskFrame(NumTasks)
TaskFrame(NumTasks).Captio
TaskFrame(NumTasks).Top = (60 + ((NumTasks - 1) * 1140))
TaskFrame(NumTasks).Left = 45
TaskFrame(NumTasks).Width = 2475
TaskFrame(NumTasks).Height
TaskFrame(NumTasks).visibl
Load StateImage(NumTasks)
StateImage(NumTasks).Conta
StateImage(NumTasks).Pictu
StateImage(NumTasks).Left = 60
StateImage(NumTasks).Top = 270
StateImage(numtasks).visib
Load SiteNameLabel(NumTasks)
SiteNameLabel(NumTasks).Co
SiteNameLabel(NumTasks).Au
SiteNameLabel(NumTasks).Fo
SiteNameLabel(NumTasks).Fo
SiteNameLabel(NumTasks).Fo
SiteNameLabel(NumTasks).Ca
SiteNameLabel(NumTasks).Le
SiteNameLabel(NumTasks).To
SiteNameLabel(NumTasks).vi
Only the TaskFrame control (it is a Frame) was displayed and the others were not. Any answers?