|
-
Nov 8th, 1999, 10:42 PM
#1
Thread Starter
New Member
Can someone please help me adding more than 10 command buttons to my form at runtime.
-
Nov 8th, 1999, 10:51 PM
#2
Create a Command Button at Design Time, set the Index Property to Zero then at Runtime..
Code:
Private Sub Form_Load()
Dim I As Integer
For I = 0 To 9
If I Then Load Command1(I)
With Command1(I)
.Move 0, I * Command1(0).Height
.Caption = "Command" & (I + 1)
.Visible = True
End With
Next
End Sub
Private Sub Command1_Click(Index As Integer)
MsgBox "You Pressed " & Command1(Index).Caption
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Nov 8th, 1999, 10:58 PM
#3
Junior Member
1. paste a command button on the form. in the properties window set the index property to 0. this will make the control the first element of a control array which u can load at run time. lets assume the control name as cmdDynamic
2. at run time have the following code in whichever event you want the controls to be loaded (i am assuming Form Load event here)
private sub Form_Load()
for Counter = 1 to NoOfComponents - 1
load cmdDynamic(Counter)
cmdDynamic(Counter).Left = cmdDynamic(Counter - 1).Left
cmdDynamic(Counter).Top = cmdDynamic(Counter - 1).Top + cmdDynamic(Counter - 1).Height
next Counter
end sub
Hope this helps
Dev
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|