|
-
July 12th, 2001, 12:20 PM
#1
Radio Buttons at run time
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
-
July 12th, 2001, 03:49 PM
#2
Re: Radio Buttons at run time
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!
-
July 12th, 2001, 03:52 PM
#3
Re: Radio Buttons at run time
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
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
|