PDA

View Full Version : آموزش: جستجوي اينكه يك گره در TreeView وجود دارد يا نه؟



milad.biroonvand
سه شنبه 06 بهمن 1388, 10:37 صبح
اگر مي خواهيد ، ببينيد ، يك گره در treeview وجود دارد يا نه ، بايد از كد زير استفاده كنيد .




Dim nCollection As TreeNodeCollection ' nCollection as "Node Collection" Dim fn As TreeNode()
Dim key As String
key = Me.textboxNodeSearch.Text

nCollection = Me.TreeView1.Nodes
fn = nCollection.Find(key, True)

' If no search results are found...
If fn.Length = 0 Then ' fn as "Found Nodes".
MsgBox("No Results Found.", MsgBoxStyle.Information, "Node Search")
End If

Dim i As Integer
For i = 0 To fn.Length - 1
Me.listboxSearchResults.Items.Add(fn(i))
Next i

End Sub 'NodeSearch




نكته ) نوع treenode بايد از نوع آرايه اي باشد .
نكته 2) بعد از find از (0) استفاده نبايد كرد .