当前位置: 代码迷 >> VB Dotnet >> 一个窗体中有多个checkbox,请教怎么确定小弟我选中了几个
  详细解决方案

一个窗体中有多个checkbox,请教怎么确定小弟我选中了几个

热度:51   发布时间:2016-04-25 02:11:15.0
一个窗体中有多个checkbox,请问如何确定我选中了几个?
一个窗体中的多个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)

试下这个!

------解决思路----------------------
遍历,或者勾选时就记录一下,取消时就减一个
  相关解决方案