vbgen Level: Moderator
 Registered: 10-10-2002 Posts: 876
|
Re: Creating Control At RunTime as well as set the properties or events of those controls
well, one way that i can show you on how to create controls during runtime is by using an array of the controls you want to use...
i searched the net for this code, and i guess it can help you, if you are willing to go this way...
'**************************************
' Name: Create New Controls At Runtime
'
' Description:This code will allow you to create a new instance
'of a control at runtime !
' By: Marc A. Foumberg
'
'
' Inputs:None
'
' Returns:None
'
'Assumes:NONE
'
'Side Effects:NONE
'This code is copyrighted and has limite
' d warranties.
'Please see http://www.Planet-Source-Cod
' e.com/xq/ASP/txtCodeId.1357/lngWId.1/qx/
' vb/scripts/ShowCode.htm
'for details.
'**************************************
'Create a new project.
'Add a command button.
'Name the button...
' Command1(0)
'As if it were an aray.
'Its sometimes easyier to create
'an aray to begin with. If you do
'be sure to delete all button except
'Command1(0).
'The Code...
Private Sub Command1_Click(Index As Integer)
Static I As Integer
I = I + 1
Load Command1(I)
Command1(I).Left = Command1(I - 1).Left + 200
Command1(I).Top = Command1(I - 1).Top + 600
Command1(I).Caption = "New Button !"
Command1(I).Visible = True
End Sub
'At runtime this will create a new
'command button.
'To add additional function you could ad
' d
'an IF statement. As follows...
Private Sub Command1_Click(Index As Integer)
On Error GoTo Handler1
'Create new button
Static I As Integer
I = I + 1
Load Command(I)
Command(I).Left = 2460
Command(I).Top = 5520
Command(I).Caption = "For Real This Time" ' change the caption
Command(I).Visible = True
' Code to unload the form when the new b
' utton is clicked
If Command(1) Then
Unload Me
End If
Handler1:
End Sub
'Email Marc at 3dtech@acwn.com with any
' questions.
'try this with other controls !
|
that good enough?
____________________________
Been busy trying to take a second degree <--it's not working out...
|