以下是控件CheckedListBox1 ItemCheck事件里的代码
Dim t As Table = Tables(e.Form.name & "_Table1")
Dim txt As String =t.Current("目录树字段")
Dim a As String=e.sender.value
Dim Selecttxt As String() = a.Split(",") '将当面选中的项目赋值给数组
Dim txts As String()=txt.Split("-")
Dim txts2 As new List(of String)
txts2.AddRange(txts) '将当前所有目字段设为集合
If e.Checked=True
For i As Integer = 0 To Selecttxt.Length-1
If not txts2.Contains(Selecttxt(i)) Then '如果不包含集合项目
If i = Selecttxt.Length-1 And i <>0 Then
txt= txt & "-"
End If
txt=txt & Selecttxt(i)
End If
Next
Else '如果为假
Dim se As String = e.Sender.Items(e.Sender.SelectedIndex)
If txts2.Contains(se) And txts2 IsNot Nothing Then
txts2.remove(se)
txt =""
For i As Integer = 0 To txts2.Count-1
txt=txt & txts2(i)
If i < txts2.Count-1 Then
txt= txt & "-"
End If
Next
End If
End If
t.Current("目录树字段")=txt
一旦运行就会出错显示
InvalidArgument=“-1”的值对于“index”无效。
参数名: index
可是如果随便勾选了左边的项目 再随意点击表格 就不会再出错了。不知道哪里有问题 请大神帮忙看一下