CosmicCharlie
Programmer
How can I modify the width of the text portion of a treeview node at run time?
I am working with a treeview control that displays client names of my company. Under certain conditions, some client names need to be flagged by making the backcolor of the node in question yellow and making the text bold. I am using this code:
Fine so far. Then I found that many of the highlighted nodes expand the text but the width of those nodes does not expand with it, so the ends of the client names are getting chopped off.
This isn't a big deal, but it looks bad.
The problem is that I cannot figure out how to get the node to widen to accommodate the extra length. I have tried playing with the Bounds property, but the various methods I use either have no apparent affect, are read only, or raise null object reference errors. I also tried applying the color and font first, then the node text, but that makes no difference. I also tried applying the formatting after the entire treeview had been populated, thinking that this would solve the null reference problem, but that didn't work either.
Does anyone know how this can be done?
RELATED QUESTION: While working on this I tried this If statement:
But .Net told me:
This seems odd. Does anyone have an answer for that?
Thank you.
Charlie
I am working with a treeview control that displays client names of my company. Under certain conditions, some client names need to be flagged by making the backcolor of the node in question yellow and making the text bold. I am using this code:
Code:
If .NeedsAssessment then
nd.BackColor = System.Drawing.Color.Yellow
nd.NodeFont = New Font("Arial", 8, FontStyle.Bold)
End If
Fine so far. Then I found that many of the highlighted nodes expand the text but the width of those nodes does not expand with it, so the ends of the client names are getting chopped off.
This isn't a big deal, but it looks bad.
The problem is that I cannot figure out how to get the node to widen to accommodate the extra length. I have tried playing with the Bounds property, but the various methods I use either have no apparent affect, are read only, or raise null object reference errors. I also tried applying the color and font first, then the node text, but that makes no difference. I also tried applying the formatting after the entire treeview had been populated, thinking that this would solve the null reference problem, but that didn't work either.
Does anyone know how this can be done?
RELATED QUESTION: While working on this I tried this If statement:
Code:
If nd.BackColor = System.Drawing.Color.Yellow Then
But .Net told me:
Operator '=' is not defined for types 'System.Drawing.Color' and 'System.Drawing.Color'.
This seems odd. Does anyone have an answer for that?
Thank you.
Charlie