Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. TreeView Control problem

TreeView Control problem

Scheduled Pinned Locked Moved C#
wpfhelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ankushmn
    wrote on last edited by
    #1

    If I have a TreeView and fill it with nodes and then decide to change one of the node's font styles to bold, the end of the text in that node gets chopped off. It seems like the TreeView isn't taking the NodeFont's style into account when calculating the width of the text. Here's the code to make it happen on a node named treeNode in a TreeView named treeView: treeNode.NodeFont = new Font(treeView.Font, FontStyle.Bold);

    J R J 3 Replies Last reply
    0
    • A ankushmn

      If I have a TreeView and fill it with nodes and then decide to change one of the node's font styles to bold, the end of the text in that node gets chopped off. It seems like the TreeView isn't taking the NodeFont's style into account when calculating the width of the text. Here's the code to make it happen on a node named treeNode in a TreeView named treeView: treeNode.NodeFont = new Font(treeView.Font, FontStyle.Bold);

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      I spotted this a few weeks ago when somebody asked how to make nodes bold... the suggestion then was to place a few spaces at the end of the text of the node, this will not be visible but will mean that there is enough space assigned to display the same text in bold. Bit of a hack, but should work! Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

      1 Reply Last reply
      0
      • A ankushmn

        If I have a TreeView and fill it with nodes and then decide to change one of the node's font styles to bold, the end of the text in that node gets chopped off. It seems like the TreeView isn't taking the NodeFont's style into account when calculating the width of the text. Here's the code to make it happen on a node named treeNode in a TreeView named treeView: treeNode.NodeFont = new Font(treeView.Font, FontStyle.Bold);

        R Offline
        R Offline
        Robert Rohde
        wrote on last edited by
        #3

        If I remember right it should work to assign a bold Font to the TreeView and initially assign all nodes a normal font. This way the tree calculates the width with the bold font and thus everything fits.

        J A 2 Replies Last reply
        0
        • R Robert Rohde

          If I remember right it should work to assign a bold Font to the TreeView and initially assign all nodes a normal font. This way the tree calculates the width with the bold font and thus everything fits.

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          OOh good idea, I never thought of that one. 5! Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

          1 Reply Last reply
          0
          • R Robert Rohde

            If I remember right it should work to assign a bold Font to the TreeView and initially assign all nodes a normal font. This way the tree calculates the width with the bold font and thus everything fits.

            A Offline
            A Offline
            ankushmn
            wrote on last edited by
            #5

            Thanx Robert Rohde ...:-D

            1 Reply Last reply
            0
            • A ankushmn

              If I have a TreeView and fill it with nodes and then decide to change one of the node's font styles to bold, the end of the text in that node gets chopped off. It seems like the TreeView isn't taking the NodeFont's style into account when calculating the width of the text. Here's the code to make it happen on a node named treeNode in a TreeView named treeView: treeNode.NodeFont = new Font(treeView.Font, FontStyle.Bold);

              J Offline
              J Offline
              Josh Smith
              wrote on last edited by
              #6

              The way I worked around this bug in the TreeView was to set the node's Text to an empty string (""), assign the bold font, then set the node's Text back to the real value. Josh

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups