Link to home
Start Free TrialLog in
Avatar of farjack1
farjack1Flag for United States of America

asked on

highlight treeview node

i want to find treeview node and highlight with some color, please tell me the solution.  
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of farjack1

ASKER

i tried this code but its not working i have tried to pass NodeID or  NodeName but still not working b/c  
nds.Length always comming 0 i dont know way

  Dim nds() As TreeNode = UcPMGroupRestrictions1.tvRestrictionByPMGroup.Nodes.Find(pNodeName, False)
            If nds.Length > 0 Then
                nds(0).BackColor = Color.Red
            End If
By setting the second parameter to False, you are ignoring any child nodes, and only top level nodes will be looked at. Is that your wish?
i tried with true as well but same length is comming 0. please suggest and property need to be set?
How are you loading your treeview? Can you show us the code?
there is no problem in my tree, tree is populated correctly,
basically i am selected value from listbox and and finding  same value in treeview that value is in treeview i know that i can see that,

but the listbox is in seperate user control and treeview is in seperate user control, i am handling this with raiseevent is this cause any problem?
 
>>there is no problem in my tree, tree is populated correctly,

That is not what I asked for. I would like to see the code you use to populate the Treeview.
this is my code

  Private Sub populateTree()

        Dim intX, j As Integer
        Dim strGID As String
        Dim resultList As ArrayList
        Dim strFID As String
        Dim strFName As String

        Dim objDataHelper As New DataHelper

        tv.Nodes.Clear()

        resultList = objDepartmentfundsDataHelper.getGF(CONSTUID)

        tv.Nodes.Add(STRID, "ROOT")
        tv.Nodes(STRID).ImageIndex = 0
        tv.Nodes(STRID).SelectedImageIndex = 0

        For intX = 0 To resultList.Count - 1

            strGID = CStr(CType(resultList.Item(intX), Groups).ID)

            tv.Nodes(0).Nodes.Add(strGID, CType(resultList.Item(intX), Groups).GName)
            tv.Nodes(0).Nodes(strGID).ImageIndex = 1
            tv.Nodes(0).Nodes(strGID).SelectedImageIndex = 1

            For j = 0 To CType(CType(resultList.Item(intX), Groups).GroupFunds.Item(0), GroupFunds).FID.Count - 1

                strFID = CStr(CType(CType(resultList.Item(intX), Groups).GroupFunds.Item(0), GroupFunds).FID.Item(j))
                strFName = CType(CType(resultList.Item(intX), Groups).GroupFunds.Item(0), GroupFunds).FundName.Item(j)

                tv.Nodes(0).Nodes(intX).Nodes.Add(CONST_F_IMAGE & strFID, strFName)
                tv.Nodes(0).Nodes(intX).Nodes(CONST_F_IMAGE & strFID).ImageIndex = 2
                tv.Nodes(0).Nodes(intX).Nodes(CONST_F_IMAGE & strFID).SelectedImageIndex = 2

            Next

        Next

        tv.ExpandAll()

        tv.Sort()

    End Sub
actually i have checked in seperate application, your code is working properly which you mentioned above, please advice what are the possibalities why it is not working with my code.

Thanks
now i am working on this b/c  my application is control based and the tree which i am trying to select the node is in seperate control and value is comming from seperate control when i am trying to find node

 Dim nds() As TreeNode = UcPMGroupRestrictions1.tvRestrictionByPMGroup.Nodes.Find(NodeName, True)

 node  length nds.Length is always zero when checked tree its node count is comming 0 although its populated.

Please give me solution