用 CheckBox 和 CheckedListBox,设计了一个产品产地的选择窗口。
在选择的时候,需要清空之前选的地址。
所以,在 MouseDown事件中,添加了下面这段代码。
代码中根据判断,只是清空 CheckBox 和 CheckedListBox 的勾选。
但是,现在点击窗口中的控件 Panel 和 Button,也都清空了 CheckBox 和 CheckedListBox 的勾选!
为什么呢? 怎么解决呢?
If e.Form.text = "产品产地" Then
For Each ctr As Object In e.Form.Controls ' 遍历 + 清空
If Typeof ctr Is WinForm.CheckedListBox Then
Dim ckL As WinForm.CheckedListBox = ctr
ckL.Value = "" ' 清空 所有 CheckedListBox 中的 所有 勾选
ElseIf Typeof ctr Is WinForm.CheckBox Then
Dim ck As WinForm.CheckBox = ctr
ck.Checked = False ' 清空 所有 CheckBox 中的 所有 勾选
ElseIf Typeof ctr Is WinForm.Panel Then
ElseIf Typeof ctr Is WinForm.Button Then
End If
Next
End If