Hello,
This is my first post, Hello to all. This also a test post to make sure that I am doing the right thing and following rules etc.
I have been searching for a way to make the treeview display multiple lines of text on each treeview node (treenode).
After searching for answers and not finding any, I stumbled on the solution in the msdn help files (search for TreeView.DrawNo de Event). It has source code that shows how to display multiple lines of text for a single node.
You need to setup the treeview by changing the drawmode so that the text is draw by the _DrawNode event.
I assign the node text, putting newlines in where I want. This text will be draw explicitly in the _DrawNode event handler.
In the _DrawNode event handler, draw the node text, using the following code as an example. This code comes directly from the help documentation.
This is the result of my efforts so far. It still needs fine tuning, but it works, and thats all I care about at the moment.
This is my first post, Hello to all. This also a test post to make sure that I am doing the right thing and following rules etc.
I have been searching for a way to make the treeview display multiple lines of text on each treeview node (treenode).
After searching for answers and not finding any, I stumbled on the solution in the msdn help files (search for TreeView.DrawNo de Event). It has source code that shows how to display multiple lines of text for a single node.
You need to setup the treeview by changing the drawmode so that the text is draw by the _DrawNode event.
Code:
treeViewForTasks.DrawMode = TreeViewDrawMode.OwnerDrawText;
Code:
childNode.Text = tr.Name + Environment.NewLine + tr.Description + Environment.NewLine + Environment.NewLine + "Incomplete";
Code:
// Draw the node text. e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));

Comment