Create New Controls At Runtime !
This code will allow you to create a new instance of a control at runtime ! Imagine. When your app is RUNNING you can create a new command button or a textbox on the fly ! The code they didn't want you to know ;)
AI
สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
ซอร์สโค้ด
'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 add '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 button 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 ! Upload
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine