如果在 vb.net 的组框中选中多个复选框,如何检查和显示

How do I check and display if multiple checkboxes are checked within a group box in vb.net

    For Each ctl As Windows.Forms.Control In Me.Controls
        If TypeOf ctl Is System.Windows.Forms.CheckBox Then
            Dim ck As System.Windows.Forms.CheckBox = ctl
            If ck.Checked Then
                intcheckboxesChecked += 1
            End If
        End If
    Next

当我显示计数时,其结果为 0 值

如果 CheckBoxesGroupBox 中,那么您必须使用 GroupBoxControls 集合而不是表格。此外,您可以使用 LINQ 查询将循环展平为单个语句:

Dim checkedBoxesCount = myGroupBox.Controls.
                                   OfType(Of CheckBox)().
                                   Count(Function(cb) cb.Checked)