With just the name of a RadioButton, how can I check/uncheck the control?
-
I'm trying to do a mapping exercise and if a user clicks on a column and it has already been mapped, I want to check the corresponding radio button. If I use a For Each loop to loop through the controls of a group box, I can find the control/radio button, I can change the Text, Font size, position and many other things, but I cannot change the Checked status. What am I missing? Thanks in advance, Steve
-
I'm trying to do a mapping exercise and if a user clicks on a column and it has already been mapped, I want to check the corresponding radio button. If I use a For Each loop to loop through the controls of a group box, I can find the control/radio button, I can change the Text, Font size, position and many other things, but I cannot change the Checked status. What am I missing? Thanks in advance, Steve
AFAIK you can get and set RadioButton.Checked; setting it might fail if it is disabled. And then there is RadioButton.PerformClick() :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
-
AFAIK you can get and set RadioButton.Checked; setting it might fail if it is disabled. And then there is RadioButton.PerformClick() :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
AFAIK? Was able to get to the Checked property by converting the Control to a Radio Button using CType.
Private Sub ChecktheRadioButton(ByVal sName as String)
Dim ctr as Control
For Each ctr in GroupBox2.Controls
If ctr.Name = sName then
CType(ctr,RadioButton).Checked = True
Exit Sub
NextEnd Sub
-
AFAIK? Was able to get to the Checked property by converting the Control to a Radio Button using CType.
Private Sub ChecktheRadioButton(ByVal sName as String)
Dim ctr as Control
For Each ctr in GroupBox2.Controls
If ctr.Name = sName then
CType(ctr,RadioButton).Checked = True
Exit Sub
NextEnd Sub
See, there is no problem whatsoever. Of course it has to be a Control that HAS a Checked property. Now try this:
CType(GroupBox2.Controls(theNameOfMyTargetRadioButton),RadioButton).PerformClick()
:)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
-
See, there is no problem whatsoever. Of course it has to be a Control that HAS a Checked property. Now try this:
CType(GroupBox2.Controls(theNameOfMyTargetRadioButton),RadioButton).PerformClick()
:)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
Beautiful. That did the trick. But still a bit confused - what is AFAIK
-
Beautiful. That did the trick. But still a bit confused - what is AFAIK
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.