Click here to Skip to main content
15,886,676 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: TreeView Find not working Pin
Eddy Vluggen5-May-13 8:45
professionalEddy Vluggen5-May-13 8:45 
GeneralRe: TreeView Find not working Pin
treddie5-May-13 9:44
treddie5-May-13 9:44 
GeneralRe: TreeView Find not working Pin
Eddy Vluggen5-May-13 10:06
professionalEddy Vluggen5-May-13 10:06 
GeneralRe: TreeView Find not working Pin
treddie5-May-13 14:51
treddie5-May-13 14:51 
GeneralRe: TreeView Find not working Pin
JR2125-May-13 20:55
JR2125-May-13 20:55 
GeneralRe: TreeView Find not working Pin
treddie5-May-13 23:02
treddie5-May-13 23:02 
AnswerRe: TreeView Find not working Pin
Eddy Vluggen6-May-13 7:45
professionalEddy Vluggen6-May-13 7:45 
GeneralRe: TreeView Find not working Pin
treddie6-May-13 11:02
treddie6-May-13 11:02 
Heheh...Your code threw me for a second. It looks like you did a C#-to-vb conversion. Smile | :) But I figured it out and made the mods to get it to work in vb.Net. (I'm not a "C" guy). Here is my change to your translation, with a caption added to the button:

VB
Imports System.Windows.Forms

Module Module1
  Dim TreeView1 As New TreeView

  Sub Main()
    'This demo is a test of how a TreeView search behaves for a node name (key) vs. the TEXT of the node as 
    'seen in the TreeView.  Searching for the text will fail.  YOU NEED THE NAME (KEY) TO DO THE SEARCH.

    Using f As New Form
      Dim btn As New Button

      btn.Dock = DockStyle.Top
      btn.Text = "Find ""Label 39"""

      AddHandler btn.Click, AddressOf BClick
      TreeView1.Dock = DockStyle.Fill

      For i As Integer = 0 To 40
        Dim key As String

        'Comment-out this line, and the search will fail,
        'because a node's NAME (its KEY) is NOT its TEXT LABEL!:
        key = String.Format("Node {0}", i)

        Dim label As String = String.Format("Label {0}", i)
        TreeView1.Nodes.Add(key, label)
      Next i

      f.Controls.Add(TreeView1)
      f.Controls.Add(btn)
      f.ShowDialog()

    End Using

  End Sub

  Private Sub BClick(ByVal s As Object, ByVal e As EventArgs)
    Dim foundNodes As TreeNode() = TreeView1.Nodes.Find("Node 39", True)
    If foundNodes.Length > 0 Then
     TreeView1.SelectedNode = foundNodes(0)
      TreeView1.Focus()
    End If

  End Sub

End Module


This makes complete sense now...The name/key is NOT the text label. Although it is best to make sure the key = text, so that you don't get confused by the results.
GeneralRe: TreeView Find not working Pin
Eddy Vluggen7-May-13 0:33
professionalEddy Vluggen7-May-13 0:33 
GeneralRe: TreeView Find not working Pin
treddie7-May-13 8:25
treddie7-May-13 8:25 
GeneralRe: TreeView Find not working Pin
Eddy Vluggen7-May-13 9:06
professionalEddy Vluggen7-May-13 9:06 
GeneralRe: TreeView Find not working Pin
treddie7-May-13 11:57
treddie7-May-13 11:57 
GeneralRe: TreeView Find not working Pin
Eddy Vluggen8-May-13 7:01
professionalEddy Vluggen8-May-13 7:01 
QuestionView the changes in the database by DATA SET... Pin
Ebrahem B Alabdaly4-May-13 6:23
Ebrahem B Alabdaly4-May-13 6:23 
AnswerRe: View the changes in the database by DATA SET... Pin
Eddy Vluggen5-May-13 8:38
professionalEddy Vluggen5-May-13 8:38 
QuestionPathTooLongException and Solutions? Pin
treddie3-May-13 9:38
treddie3-May-13 9:38 
AnswerRe: PathTooLongException and Solutions? Pin
Eddy Vluggen5-May-13 9:43
professionalEddy Vluggen5-May-13 9:43 
GeneralRe: PathTooLongException and Solutions? Pin
treddie5-May-13 9:50
treddie5-May-13 9:50 
GeneralRe: PathTooLongException and Solutions? Pin
Eddy Vluggen5-May-13 10:04
professionalEddy Vluggen5-May-13 10:04 
QuestionHow do i save all opened windows Pin
Member 46241693-May-13 3:16
Member 46241693-May-13 3:16 
AnswerRe: How do i save all opened windows Pin
GuyThiebaut3-May-13 4:23
professionalGuyThiebaut3-May-13 4:23 
QuestionHow do i save all opened windows Pin
Member 46241693-May-13 2:56
Member 46241693-May-13 2:56 
QuestionTry Catch does not Execute Catch code Pin
treddie2-May-13 18:31
treddie2-May-13 18:31 
AnswerRe: Try Catch does not Execute Catch code Pin
Richard MacCutchan2-May-13 21:41
mveRichard MacCutchan2-May-13 21:41 
GeneralRe: Try Catch does not Execute Catch code Pin
treddie2-May-13 22:02
treddie2-May-13 22:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.