|
-
Nov 22nd, 2000, 08:25 AM
#1
Thread Starter
Lively Member
Hello,
How can I put multiple controls to a form at runtime?
For instance:
At runtime I want to put 2 textboxes, 1 combobox and 1 checkbox
Thanks
-
Nov 22nd, 2000, 08:31 AM
#2
Frenzied Member
Go look that thread
-
Nov 22nd, 2000, 08:41 AM
#3
Thread Starter
Lively Member
Yes, I knew that already. But with this code, you can only put one object to the form.
How can I put some more objects to my form?
-
Nov 22nd, 2000, 08:47 AM
#4
Frenzied Member
Code:
Option Explicit
' Remarks:
' Dynamically add a new button to the form. The
' item to add, a button in this case, must be a
' member of the VB object as displayed in the
' Object Browser. The second parameter is the
' the new control's name.
'
Private WithEvents btnObj As CommandButton
Private Sub btnObj_Click()
'
' Respond to the new button's Click event.
'
MsgBox "This button was added at run time!"
End Sub
Private Sub cmdAdd_Click()
Set text1 = Controls.Add("VB.TextBox", "text1")
'
With text1
.Visible = True
.Text = "&Dynamically Added Text"
.Top = 0
.Left = 0
.Width = 2400
.Height = 500
End With
Set text2 = Controls.Add("VB.TextBox", "text2")
'
With text2
.Visible = True
.Text = "&Dynamically Added Text"
.Top = 0
.Left = 0
.Width = 2400
.Height = 500
End With
Set cbo1 = Controls.Add("VB.ComboBox", "cbo1")
'
With cbo1
.Visible = True
.Caption = "&Dynamically Added Combobox"
.Top = 0
.Left = 0
.Width = 2400
.Height = 500
End With
Set Chk1 = Controls.Add("VB.CheckBox", "Chk1")
'
With Chk1
.Visible = True
.Caption = "&Dynamically Added Checkbox"
.Top = 0
.Left = 0
.Width = 2400
.Height = 500
End With
End Sub
What seem to be the problem!
Just change the top,left,width and height
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
|