Click here to Skip to main content
15,890,512 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow to export the data from datagridview & all the data on the form1.vb make a report Pin
chandan H T5-May-13 1:24
chandan H T5-May-13 1:24 
AnswerRe: How to export the data from datagridview & all the data on the form1.vb make a report Pin
Eddy Vluggen5-May-13 8:49
professionalEddy Vluggen5-May-13 8:49 
QuestionTreeView Find not working Pin
treddie4-May-13 22:17
treddie4-May-13 22:17 
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 
Here is a code that I made by several examples that I found:
VB
  Public Class cTreeviewFind
    Inherits TreeView
#Region "Functions"
    Function SearchTree(ByVal root As TreeNode, ByVal text As String) As System.Collections.Generic.List(Of TreeNode)
      Dim nodes As New System.Collections.Generic.List(Of TreeNode)()

      ' case insensitive
      If root.Text.ToUpper().Contains(text.ToUpper()) Then
        nodes.Add(root)
      End If

      For Each node As TreeNode In root.Nodes
        Dim subNodes As System.Collections.Generic.List(Of TreeNode) = SearchTree(node, text)
        If (subNodes.Count > 0) Then
          nodes.AddRange(subNodes)
        End If
      Next
      Return nodes
    End Function

    ''' <summary>
    ''' Zoek in welke node een tekst voorkomt
    ''' </summary>
    ''' <param name="_nodeCollection"></param>
    ''' <param name="SearchVal"></param>
    ''' <param name="CaseSensitief"></param>
    ''' <param name="CompleteValue"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function FindNode(ByVal _nodeCollection As TreeNode, ByVal SearchVal As String, Optional ByVal CaseSensitief As Boolean = False, Optional ByVal CompleteValue As Boolean = False, Optional ByVal refind As Boolean = False) As TreeNode
      Dim tmpNode As TreeNode = Nothing
      Static bFoundSelectedNode As Boolean
      If refind Then bFoundSelectedNode = False
      If Me.SelectedNode.Equals(Me.Nodes(0)) Then
        bFoundSelectedNode = True
      End If
      For Each _c As TreeNode In _nodeCollection.Nodes
        If _c.Equals(Me.SelectedNode) Then
          bFoundSelectedNode = True
        End If
        If bFoundSelectedNode = False Then
          If _c.Nodes.Count > 0 Then
            tmpNode = FindNode(_c, SearchVal, CaseSensitief, CompleteValue)
            If bFoundSelectedNode = True AndAlso Not tmpNode Is Nothing Then
              Return tmpNode
            End If
          End If
        Else
          If CaseSensitief Then
            If CompleteValue Then
              If _c.Text = SearchVal AndAlso _c.Equals(Me.SelectedNode) = False Then Return _c
              If _c.Nodes.Count > 0 Then tmpNode = FindNode(_c, SearchVal, CaseSensitief, CompleteValue)
              If Not tmpNode Is Nothing Then
                Return tmpNode
              End If
            Else
              If _c.Text.IndexOf(SearchVal) >= 0 AndAlso _c.Equals(Me.SelectedNode) = False Then Return _c
              If _c.Nodes.Count > 0 Then tmpNode = FindNode(_c, SearchVal, CaseSensitief, CompleteValue)
              If Not tmpNode Is Nothing Then
                Return tmpNode
              End If
            End If
          Else 'not sensitief
            If CompleteValue Then
              If _c.Text.ToLower = SearchVal.ToLower AndAlso _c.Equals(Me.SelectedNode) = False Then Return _c
              If _c.Nodes.Count > 0 Then tmpNode = FindNode(_c, SearchVal, CaseSensitief, CompleteValue)
              If Not tmpNode Is Nothing Then
                Return tmpNode
              End If
            Else
              If _c.Text.ToLower.IndexOf(SearchVal.ToLower) >= 0 AndAlso _c.Equals(Me.SelectedNode) = False Then Return _c
              If _c.Nodes.Count > 0 Then tmpNode = FindNode(_c, SearchVal, CaseSensitief, CompleteValue)
              If Not tmpNode Is Nothing Then
                Return tmpNode
              End If
            End If
          End If
        End If
      Next
      Return Nothing
    End Function
#End Region 'functions
  End Class



Jan
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 
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 

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.