Click to See Complete Forum and Search --> : How do I add an option button to a form at runtime? plz help


faisal664
December 6th, 1999, 07:44 PM
help!

December 6th, 1999, 08:48 PM
in VB6 only:

private withevents btnObj as OptionButton

private Sub Form_Load()
set btnObj = Controls.Add("VB.OptionButton", "btnObj")
With btnObj
.Visible = true
.Width = 2000
.Caption = "Dynamic Button"
.Top = 1000
.Left = 1000
End With
End Sub
'for more sample see MSDN Dynamic Control Addition



In VB5 you have to have at least 1 option button with Index = 0 (Array), and using Load statement you can add new elements to that array:

Load Option1(1)
Option1(1).Top=2000
........



You can do it ofcourse in VB6 too.
Vlad

faisal664
December 6th, 1999, 09:05 PM
thanks so much Vlad! <bow>

January 11th, 2000, 02:56 PM
Why not just add the option control to your form, set it's visible property to false at design time and toggle this property as needed at run-time in the corresponding events.