以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] 字典问题 已添加了具有相同键的项 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=86518) |
-- 作者:lzzhx -- 发布时间:2016/6/19 15:49:00 -- [求助] 字典问题 已添加了具有相同键的项 下面代码是一个按钮单击的代码:执行一次正常,第二次单击按钮就出现 已添加了具有相同键的项 ,请老师看看问题在什么地方? 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
|
-- 作者:lzzhx -- 发布时间:2016/6/19 16:05:00 -- 已找到问题,少加了str1 = str1.trim("|") |