Click to See Complete Forum and Search --> : Creating a Button at Runtime


giacomitti
August 3rd, 2001, 08:55 AM
How I can create a CommandButton at runtime???

Thanks
Arnaldo

Cimperiali
August 3rd, 2001, 08:58 AM
There are many examples here in CodeGuru. Use the search option (on top left of page). Or have a look at this:
http://codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vb&Number=53553&Search=true&Forum=vb&Words=balena&Match=Whole&Topic=&Searchpage=0&Limit=25


Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

RSH
August 3rd, 2001, 10:25 PM
Have the button on your form but make it invisible
When you want it to appear
Command1.Visible = true
73 RSH

Cimperiali
August 6th, 2001, 02:59 AM
You may also have a button invisible with index = 0 and when you need one more, you can use the load statement incrementing index
ie:

load command1(ubound(command1+1))
with command1(ubound(command1))
left=command1(ubound(command1)-1).left +command1(ubound(command1)-1).width
top=command1(ubound(command1)-1).top
caption="AAA"
visible = true
end with




Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

urs
August 9th, 2001, 12:22 PM
private withevents cmd as commandbuttons
'on any events
set cmd = controls.add("vb.commandbutton","name")
cmd.visible=true