过程:一个节点与节点的文本树视图控制加入= textbox1.text防止重复(VB.NET)
欲防止另外的重复节点即比方说,如果一个节点在下一次添加文本“ABC”时,不应将具有文本“ABC”的节点添加到树视图控件中。
我尝试了以下方法,但无法达到预期效果。 方法A)
Dim list As New ArrayList
list.Add(TextBox1.Text)
if list.Contains(Textbox1.Text) then
MsgBox("Use different name")
else
.....code to add node with text
end if
方法B)
if Treeview1.Nodes.Count > 0 then
For i = 0 to Treeview1.Nodes.Count
if Treeview1.Nodes(i).Text=Textbox1.Text then
MsgBox("Use different name")
end if
next
else
........code to add node with text
end if
我无法理解的解决方案,建议C#在这个论坛。
任何帮助将非常感激。
谢谢
方法B +您的建议修改=解决方案。我再次尝试了方法A,但它添加了重复节点。我不确定那里有什么问题。非常感谢你的时间和帮助。 – mrn