|
-
Nov 7th, 2000, 09:19 AM
#1
Thread Starter
New Member
How can you add events to controls added in runtime
using the ADD method?
-
Nov 7th, 2000, 09:24 AM
#2
_______
<?>
Code:
'add a command button to a form dynamically at run time
Option Explicit
Private WithEvents btnObj As CommandButton
Private Sub btnObj_Click()
MsgBox "This is a dynamically added button."
End Sub
Private Sub Form_Load()
Set btnObj = Controls.Add("VB.CommandButton", "btnObj")
With btnObj
.Visible = True
.Width = 3000
.Caption = "This button was created on the fly!"
.Top = 1000
.Left = 1000
End With
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 7th, 2000, 09:37 AM
#3
New Member
Originally posted by Rwhite
How can you add events to controls added in runtime
using the ADD method?
Try using the CreateEventProc Method. If this doesn't help, let me know.
-
Nov 7th, 2000, 09:48 AM
#4
_______
<?>
johnson_m
Code:
If you use the code I pasted the events come with the button. All you have to do is use them..ie>
Private Sub btnObj_Click()
MsgBox "This is a dynamically added button."
End Sub
or any other event belonging to the control created...you just have to choose to use.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 10th, 2000, 06:02 PM
#5
Frenzied Member
How would you make more than one?
retired member. Thanks for everything 
-
Nov 10th, 2000, 06:59 PM
#6
Hyperactive Member
Same way as you made the first.
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
|