下面代码是一个按钮单击的代码:执行一次正常,第二次单击按钮就出现 已添加了具有相同键的项 ,请老师看看问题在什么地方?
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim str As String = e.Form.Controls("txtColVisibleWidth").text
Dim str1 As String = ""
Dim dic As new Dictionary(Of String, String)
Dim ary As String() = str.split("|")
For i As Integer = 0 To ary.length-1 Step 2
dic.Add(ary(i), ary(i+1))
Next
If trv.SelectedNode.Index > 0 Then
trv.SelectedNode.MoveUp
For Each node As WinForm.TreeNode In trv.AllNodes
If dic.ContainsKey(node.text) = True Then
str1 = str1 & "|" & node.text & "|" & dic(node.text)
Else
str1 = str1 & "|" & node.text & "|100"
End If
Next
e.Form.Controls("txtColVisibleWidth").text = str1
End If