[英]How to get the checked items in checklistbox
I have a checklistbox and the items of it came from my database (tbl_Section) so it loads all the Section Number (Primary Key). 我有一个复选框,它的项目来自我的数据库(tbl_Section),因此它加载了所有的节号(主键)。 I have 5 Section Numbers, and 3 of it will be assigned to only one teacher.
我有5个科目编号,其中3个科目编号将仅分配给一位老师。 I'm thinking of using While-statement but i dont know how.
我正在考虑使用While语句,但我不知道如何使用。
To make it simpler to you, this is what i need to do: 为了让您更简单,这是我需要做的:
While //index(number) is checked
//do something
Else (i know it should not be ELSE, but i dont know what keyword is to be used)
//do something
End While
Thanks a lot! 非常感谢!
What you want to do is iterate through every item in your checkbox. 您要做的是遍历复选框中的每个项目。 For each item, you check if it is checked, then you act accordingly :
对于每个项目,请检查是否已选中,然后采取相应的措施:
'We will run through each indice
For i = 0 To CheckedListBox1.Items.Count - 1
'You can replace As Object by your object type
'ex : Dim Item As String = CType(CheckedListBox1.Items(i), String)
Dim Item As Object = CheckedListBox1.Items(i)
'We ask if this item is checked or not
If CheckedListBox1.GetItemChecked(i) Then
'Do something if Item is checked
Else
'Do something else if Item is not checked
End If
Next
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.