Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find out which radio button in a groupbox is checked

Status
Not open for further replies.

MrsMope987

Programmer
Sep 27, 2007
23
Hello All,
I am attempting to loop through all controls on a form, find the panel controls and loop through those contorls. I also want to loop through the controls on a gorupbox and pull the item that is checked, if it is checked then I want to pull the tabIndex, Name, and Text to my dataset for a crystal report. This is what I have, but it isn't right
Code:
 ElseIf TypeOf ctl Is GroupBox Then
                For Each grpCtl As Control In CType(ctl, GroupBox).Controls
                    If [b][blue]******I want it to say ; if radio button is checked then *****[/blue][/b]
                        str(0) = grpCtl.TabIndex
                        str(1) = grpCtl.Name.ToString
                        str(2) = grpCtl.Text

                        ds.Tables("OrderInfo").Rows.Add(str)
                    End If
                Next
 
You should be able to use the .Checked property.
If it is true then it has been selected.
 
Zarkon4,
how do I reference the control to see if it is checked, that is where I am stuck:
Code:
 For Each grpctl As Control In CType(ctl, GroupBox).Controls
                    If TypeOf grpctl Is RadioButton Then
                      [b][blue](I know this line isn't right, but I don't know what IS correct)[/blue][/b]  If CType(grpctl, RadioButton).Checked = True Then
                            str(0) = grpctl.TabIndex
                            str(1) = grpctl.Name.ToString
                            str(2) = grpctl.Text
                            ds.Tables("OrderInfo").Rows.Add(str)
                        End If
                    ElseIf TypeOf grpctl Is CheckBox Then
                        If CType(grpctl, CheckBox).Checked = True Then
                            str(0) = grpctl.TabIndex
                            str(1) = grpctl.Name.ToString
                            str(2) = grpctl.Text
                            ds.Tables("OrderInfo").Rows.Add(str)
                        End If
                    End If


 
(I know this line isn't right, but I don't know what IS correct) If CType(grpctl, RadioButton).Checked = True


Actually it is right. that would be how you would check it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top