Handling Frames & Radio Buttons

I have a frame1  on a form. And Frame1 contains Frame2. Frame2 is having 3 Radio buttons. Can any one help mw how to generate a control array for Frame2 Dynamically.
I have used the following to generate frame2 dynamically
load frame2(1). But the dynamically created frame(ie, Frame2(1)) is not having the radio buttons.
I need a new frame exactly same as that of frame2(0)(ie., created at design time which is a container for 3 radio buttons).
Thanks,
Raju
kbalarajuAsked:
Who is Participating?
 
amebaConnect With a Mentor Commented:
>Ameba said it correctly
Set ameba.points = 25 ' try this :)
0
 
caraf_gCommented:
You're not going to like this answer but it's the truth. Get into the more object-oriented aspects of VB and learn how to make a user control. Then it's easy. Create a user control containing your frame and 3 radio buttons and you can then have as many of those as you like on the form, whether in or outside control arrays.
0
 
kbalarajuAuthor Commented:
I'm using the following code & could able to generate them. but the problem is the container is not being change for the option buttons eve though I set them.
Could you pl. look at the code & figure out what the problem is?
    'This variable is used for creating option buttons dynamically(Index value for the Option button to be created)
    'Bcoz we have 3 design time option buttons in frame2(0)(So, indexes will be 0,1,2)
    j = 3
    'Create Charts dynamically & Display charts
    'If i is 0 then use the design time controls
    For i = 0 To 3
        If (i > 0) Then 'Create controls Dynamically
            'Create chart control & Set it's left property
            Load CityDivisions(i)
            CityDivisions(i).Left = CityDivisions(i - 1).Left + CityDivisions(i - 1).Width + 5
           
            'Create frame Control & Set Properties
            Load Frame2(i)
            Frame2(i).Left = Frame2(i - 1).Left + Frame2(i - 1).Width + 250
            Frame2(i).Visible = True
            Frame2(i).Caption = "Radio Group" & Str(i)
            Frame2(i).BorderStyle = 0
           
            ''Create Option buttons whose container is above created frame
            For k = 1 To 3  'Create Totally 3 option buttons
                'Create an option button
                Load Option1(j)
                'Set it's container property so that Option button belongs to newly created frame
                Option1(j).Container = Frame2(i)
                'Set other properties
                Option1(j).Visible = True
                Option1(j).Caption = Option1(j Mod 3).Caption
                'Option button left value with in the frame
                Option1(j).Left = 435
                Option1(j).Top = Option1(j Mod 3).Top
                j = j + 1
            Next k
        End If
       
        'Call the procedure to draw the chart
        DrawCityDivisionChart CityDivisions(i), ("Los Angeles" + Trim(Str(i))), i
    Next i
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
twardCommented:
Use the following function:

Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Call SetParent(Option1(3).hWnd, Frame1(1).hWnd)
0
 
amebaCommented:
Option1(j).Container = Frame2(i) ' this will generate error

Set Option1(j).Container = Frame2(i)
0
 
kbalarajuAuthor Commented:
I don't want to use any API Calls. Need modification to my code. Ameba said it correctly.
0
 
kbalarajuAuthor Commented:

Thanks Everyone for helping me!
Ameba.points.committ
-Raju
0
 
amebaCommented:
Me.Thanks
0
 
caraf_gCommented:
;-)
0
All Courses

From novice to tech pro — start learning today.