Looping through radiobuttons

  • Thread starter Thread starter lgbjr
  • Start date Start date
L

lgbjr

Hi All,

I have 5 radiobuttons in a groupbox and I'm trying to uncheck all of them:

Dim ctrl as Control
For each ctrl in GB.Controls
If TypeOf ctrl Is RadioButton Then
ctrl.Checked=False 'This doesn't work!
Endif
Next

I can change ctrl from Control to RadioButton, but there are other controls
in the groupbox (not radiobutons).

Is there an easier way to uncheck all of the radiobuttons in a groupbox?

TIA
Lee
 
"lgbjr"

You get probably a lot of answers on this easy one.

DirectCast(ctrl,RadioButton).Checked=False

Cor
 
lgbjr said:
Hi All,

I have 5 radiobuttons in a groupbox and I'm trying to uncheck all of them:

Dim ctrl as Control
For each ctrl in GB.Controls
If TypeOf ctrl Is RadioButton Then
ctrl.Checked=False 'This doesn't work!

DirectCast(ctrl, RadioButton).Checked = False 'This should work! :)
Endif
Next

Is there an easier way to uncheck all of the radiobuttons in a groupbox?

Don't think so.
 
Back
Top