Reputation: 16697
I have some very plain radio buttons in a very plain group box in a very plain WinForms form, in a very plain VB.NET project. This is as simple as possible.
The odd behaviour is that if one is selected, and I click another, the selected radio box unchecks, and that's it. A second click is required to select the clicked radio button.
Designer code for one of the radio buttons:
Me.rbPhaseM00.AutoSize = True
Me.rbPhaseM00.CausesValidation = False
Me.rbPhaseM00.Checked = Global.CnstrSirfNetIntrc.My.MySettings.Default.rbPhaseM00
Me.rbPhaseM00.DataBindings.Add(New System.Windows.Forms.Binding("Checked", Global.CnstrSirfNetIntrc.My.MySettings.Default, "rbPhaseM00", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged))
Me.rbPhaseM00.Location = New System.Drawing.Point(10, 19)
Me.rbPhaseM00.Name = "rbPhaseM00"
Me.rbPhaseM00.Size = New System.Drawing.Size(46, 17)
Me.rbPhaseM00.TabIndex = 21
Me.rbPhaseM00.Text = "M00"
Me.rbPhaseM00.UseVisualStyleBackColor = True
What property is causing this? There are no events attached to the radio buttons, no other controls in the group box.
Upvotes: 2
Views: 312
Reputation: 942207
There are two. First is the Parent, they all have to have the same one. Double-check that with View + (Other Windows) + Document Outline, verify that the radio button controls are all nested inside the group box and not just overlapping it. Drag + drop to fix.
And they all have to have the AutoCheck property set to True.
After edit: the data binding looks like a hazard. Unbind to test. There are several existing SO questions that talk about it, find them by googling "Winforms databinding radiobuttons".
Upvotes: 4