Skip to content

How to control the color of the text in a TreeView, if it is possible? #3588

Answered by tznind
Andras-Csanyi asked this question in Q&A
Discussion options

You must be logged in to vote

The ColorGetter delegate allows you to provide a function that returns a ColorScheme for each node. Below is an example that renders directories in green, executables in red and everything else in white.

Note that you return a ColorScheme not an Attribute or a Color

  • ColorScheme: A collection of Attribute to be used depending on state (normal, focused, disabled etc)
  • Attribute : A foreground and background color
  • Color : A color

For the example I have used delegate for tree building, you can read more about that approach in Tree View Deep Dive. It is not a requirement though, ColorGetter delegate works just fine on regular TreeView too.

I assume it is not as the content of the node "field…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BDisp
Comment options

Answer selected by Andras-Csanyi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants