Click to See Complete Forum and Search --> : Radio Buttons at run time
sankalp
July 12th, 2001, 12:20 PM
Hi
Am developing a project in VB, want to know if there is a way by which i can create radio buttons at run time. All i want to do is querry a database and depending on the records want to create radio buttons equal to the number of records returned by my querry.
How do I do that? An early reply/suggestion would really help
Thanks
vampyre
July 12th, 2001, 03:49 PM
What you need to do is place a single radio button on the form, and then set it's index property to 0. During runtime you can then use the Load() function to load any other index of that radio button. Then you can set it's top and left properties to distinct it from the original button. Similar, using the Unload() function, you can remove the radio button indexes you no longer need. For example:
private Sub DoThing()
for x = 1 to NumberOfRecords
Load MyRadioButton(x)
next x
End Sub
I hope my information was useful!
michi
July 12th, 2001, 03:52 PM
Hi,
You can use the "Load" function to dynamically create a control at run time.
Firstly, let's create a model radio button control in the layout of the form, set the index=0, and visable=False. The actually radio button arrays will be created as following:
======
i=1
rs.MoveFirst
While rs.EOF=False
Load Option1(i)
Option1(i).Caption = rs!YourField
Option1(i).Top = Option1(i - 1).Top + Option1(i - 1).Height
Option1(i).Left = Option1(i - 1).Left
Option1(i).Value = False 'You can decide if it should be selected
'Make sure the just created radio button to be visible
Option1(i).Visible = True
i=i+1
rs.MoveNext
Wend
=======
Hope this helps.
Regards,
Michi
MCSE, MCDBA
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.