1

I have a treeview on my ASP.Net page and for some reason the text on some nodes gets cut off, I am programatically adding all the nodes and am aware of the existing issue listed here: http://support.microsoft.com/?scid=kb%3Ben-us%3B937215&x=8&y=13 however I am not changing the font and as you see in the code below this fix does not work for me.

 Private Sub populateTreeView()

'Code that gets the data is here

      Dim ParentIds As List(Of Integer) = New List(Of Integer)

      For Each row As DataRow In ds.Rows

         If ParentIds.Contains(row("ParentID")) Then
            '' Do Nothing 
         Else
            ParentIds.Add(row("ParentID"))
         End If
      Next

      For Each Parent As Integer In ParentIds
         Dim parentNode As New System.Web.UI.WebControls.TreeNode

         For Each child In ds.Rows
            If (child("ParentID") = Parent) Then

               Dim childNode As New System.Web.UI.WebControls.TreeNode

               parentNode.Text = child("ParentDescription")
               parentNode.Value = child("ParentID")
               parentNode.Expanded = False

               childNode.Text = child("ChildDescription")
               childNode.Value = child("ChildID")


               parentNode.SelectAction = TreeNodeSelectAction.None
               parentNode.ChildNodes.Add(childNode)
            End If
         Next
         trvItem.Nodes.Add(parentNode)
      Next

      'This is just added to test the MS fix
      trvItem.Nodes(0).Text += String.Empty
   End Sub

The strange thing is that this issue only appears in IE, I have tested it in chrome and Firefox and both browsers display the text perfectly.

When I select a node this fixes the problem and all text displays as normal.

Any ideas as to what is going wrong here would be great as I'm clueless right now.

Thanks

2
  • Sounds like an IE-specific CSS problem. If you post a URL to the page I'm sure you will get someone CSS-savvy to diagnose the problem. Commented Nov 15, 2011 at 17:46
  • @JustinGrant sadly I cant its a company Intranet page. I will have a look at the CSS but im pretty sure there isnt any directly applied to the Treeview itself Commented Nov 16, 2011 at 9:18

2 Answers 2

2
tv1.LabelEdit = True

tv1.Nodes(0).Nodes(0).BeginEdit()

tv1.Nodes(0).Nodes(0).NodeFont = oNewFont

tv1.Nodes(0).Nodes(0).EndEdit(False)

tv1.LabelEdit = False
Sign up to request clarification or add additional context in comments.

Comments

0

Marking this as closed since I never received an answer which solved the problem.

I managed to work around it by using the javascript postback to select one of the items on load, thus forcing the text to display correctly. I think this is an extension of the bug I linked in my original question.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.