一个窗体中的多个checkbox,通过遍历怎么确定一共选中了几个?
我写了一部分代码,后面的就不知道怎么写了
Dim chk as controls
for each chk in me.controls
if type of chk is checkbox then
if .....
n+=1
------解决思路----------------------
Dim count As Integer = Me.Controls.OfType(Of CheckBox)().Where(Function(x) x.Checked).Count()
------解决思路----------------------
Dim chk as controls
for each chk in me.controls
if type of chk is checkbox then
if(ctype(chk,checkbox).checked) then
n+=1
end if
end if
end for
------解决思路----------------------
Dim n As Integer
For Each chk As Control In Me.Controls
If chk.GetType.Equals(GetType(CheckBox)) Then
n += 1
End If
Next
Msbox.Show("Checkbox选中的共有" & n)
试下这个!
------解决思路----------------------
遍历,或者勾选时就记录一下,取消时就减一个