Dear all,
I would like to figure out a way to add controls to a form using specs
stored in a table. Any assistance in fleshing this idea out would be
greatly appreciated. I'm using VB6.
Right now I am thinking I would loop through the specs table
(containing control name, control type, width, max length, etc) and
print lines of code to a text file. The code would look something
like the following:
Dim lblcontrol1 As Label
Set lblcontrol1 = Controls.Add("V B.Label", "lblControl 1")
lblcontrol1.Vis ible = True
Dim WithEvents txtControl1 As TextBox
Set txtControl1 = Controls.Add("V B.TextBox", "txtControl 1")
txtControl1.Vis ible = True
The code generator would substitute the appropriate control names,
property settings, and so forth.
I would then need to run this code at design time to get the controls
on the form, but I'm not sure how to create a form and run this code.
I can put it in the Form_Load event, but then the controls are created
only at run time, and I would like to be able to save the controls on
the form.
Can anyone point me in the right direction?
Thanks,
Chris
I would like to figure out a way to add controls to a form using specs
stored in a table. Any assistance in fleshing this idea out would be
greatly appreciated. I'm using VB6.
Right now I am thinking I would loop through the specs table
(containing control name, control type, width, max length, etc) and
print lines of code to a text file. The code would look something
like the following:
Dim lblcontrol1 As Label
Set lblcontrol1 = Controls.Add("V B.Label", "lblControl 1")
lblcontrol1.Vis ible = True
Dim WithEvents txtControl1 As TextBox
Set txtControl1 = Controls.Add("V B.TextBox", "txtControl 1")
txtControl1.Vis ible = True
The code generator would substitute the appropriate control names,
property settings, and so forth.
I would then need to run this code at design time to get the controls
on the form, but I'm not sure how to create a form and run this code.
I can put it in the Form_Load event, but then the controls are created
only at run time, and I would like to be able to save the controls on
the form.
Can anyone point me in the right direction?
Thanks,
Chris
Comment