|
-
Sep 29th, 2000, 03:50 PM
#1
Thread Starter
New Member
Hi everybody! does anyone know how to create dynamic radio buttons? i need to display a list of choices from a database, but i don't know how to determine the number of buttons and assign 'em values during run time.
Thx all
-
Sep 29th, 2000, 04:54 PM
#2
Fanatic Member
With all respect, forget the "option buttons" (which is the same as radio buttons).
If you have an "arbitrary" or "unpredictable" number of options, use a list box.
-
Sep 29th, 2000, 04:58 PM
#3
If you have VB6, you can create them from scratch like this:
Code:
Private Sub Command1_Click()
Controls.Add "VB.OptionButton", "Option1"
Me!Option1.Move 0, 0
Me!Option1.Caption = Text1
Me!Option1.Visible = True
End Sub
Or if you have VB5, you can load them from a Control Array. Add an OptionButton and set its Index to 0.
Code:
For I = 1 To 100
Load Option1(i)
Option1(i).Move 0, 0
Option1(i).Visible = True
Next I
-
Sep 29th, 2000, 05:01 PM
#4
I just forgot, you can also use CreateWindowExb.
Code:
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const WS_CHILD = &H40000000
Private Const BS_RADIOBUTTON = &H4&
Private Sub Form_Load()
retval = CreateWindowEx(0, "Button", "Button1", WS_CHILD Or BS_RADIOBUTTON, 32, 32, 64, 64, hwnd, 0, App.hInstance, ByVal 0&)
ShowWindow retval, 1
End Sub
-
Sep 30th, 2000, 05:19 PM
#5
Thread Starter
New Member
Thank you for answering... it was a great help...
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
|