AdamsLair / treeviewadv

Forked from http://sourceforge.net/projects/treeviewadv/
Other
54 stars 47 forks source link

Feature to add multi-line text to a node #4

Closed nerndt closed 8 years ago

nerndt commented 8 years ago

Great Control! Have you thought about multi-line text for a node label?

Here is something I found on the web that may help (This is from a syncfusion control but it may be helpful):

How to create Multiline text nodes in TreeViewAdv control

MultiLine text node can be created using OwnerDrawNode property. Subscribe to the event BeforeNodePaint and change the size of the TreeNodeAdv according to the size of the string.Size of the string could be calculated by using MesureString method.Then draw the text using Draw method C# // Creating multiline text nodes private void treeViewAdv1_BeforeNodePaint(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvPaintEventArgs e) { // Paint a custom background around the text area: TreeNodeAdv node = e.Node; Brush foreBrush = new SolidBrush(Color.Red ); System.Drawing.SizeF tSize = e.Graphics.MeasureString( "MultiLine \nText", node.Font ); e.Node.Height = tSize.ToSize().Height; e.Graphics.FillRectangle(new SolidBrush(Color.LightBlue ), e.Node.Bounds.X , e.Node.Bounds.Y , e.Node.Bounds.Width , e.Node.Height ); e.Graphics.DrawString("MultiLine \nText", node.Font, foreBrush, node.TextBounds.Right + 2,node.Bounds.Y + (node.Height-node.TextBounds.Height)/2); }

ilexp commented 8 years ago

Hey! Thanks for your suggestion, but unfortunately, I'm not the maintainer of this control and this repository is just a personal GitHub mirror of the real thing. :)

You can find it here: http://sourceforge.net/projects/treeviewadv/