|
-
Dec 13th, 2002, 04:30 PM
#1
Thread Starter
Hyperactive Member
declaring and adding a new control
How can i add a new control to a form and set its settings? Like say i want to add a command button that's 100x100 and located at (100,100), how exactly would id o this... if i can?
-
Dec 13th, 2002, 04:49 PM
#2
I don't think you can.The best you can do is have a command button already on the form and have it's visible property set to false.When whatever you want happens and you want to create a command button,just set the property to visible and set the top,left properties to 100.
-
Dec 13th, 2002, 04:56 PM
#3
VB Code:
Option Explicit
Dim WithEvents cmd As CommandButton
Private Sub AddButton()
Set cmd = Controls.Add("VB.CommandButton", "cmdHello")
cmd.Caption = "Hello"
cmd.Width = 100
cmd.Height = 100
cmd.Visible = True
cmd.Move 100, 100
End Sub
-
Dec 14th, 2002, 05:50 PM
#4
Frenzied Member
Hey pnish, that's cool!
But how would you call other controls?
vb.Image
vb.Picturebox
...?
I am just guessing...
Where could we know more about that?
We miss you, friend...  Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
-
Dec 14th, 2002, 06:03 PM
#5
The picture isn't missing
if you search in the registry for VB.CommandButton there should also be others that youu can use.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Dec 14th, 2002, 06:13 PM
#6
Just make the appropriate changes from command button to label
ie :
VB Code:
Option Explicit
Dim WithEvents lbl As Label
Private Sub AddButton()
Set cmd = Controls.Add("VB.Label", "lblHello")
lbl.Caption = "Hello"
lbl.Width = 100
lbl.Height = 100
lbl.Visible = True
lbl.Move 100, 100
End Sub
-
Dec 15th, 2002, 01:32 AM
#7
But how would you call other controls?
vb.Image
vb.Picturebox
I'm not sure but I think you can use this method with most controls. You need to Dim them using WithEvents so you can respond to their events.
Try looking in MSDN for Controls Collection and doing a little experimenting.
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
|