C # Treeview Node with formatted text, e.g. tabs and newlines

Is it possible (using C # TreeView's background) to have multi-line TreeNodes?

In addition, you can add control characters to TreeNode text, for example. '\ T'? The same effect can be achieved by adding columns to the TreeNode. is it possible?

+3
source share
3 answers

I do not think this is possible using WinForms, at least without drawing your own nodes. You can use the owner-bound treenode to accomplish this in WinForms, though, I don’t know.

However, this is supported using WPF.

+2
source

, ASP.NET WinForms. ASP.NET, PRE ...?

, , RaView-Tree TreeView, , HTML / , TreeView ASP.NET. ( , Ra-Ajax)

TreeView , . , , " " - - ...

+1

TreeNode. , :

The Console font has an equal space for each letter, so you can easily run spaces. The GetEmptyInfoByIndex method returns the custom length of the string of spaces to fill the gap to the specified length. Here = 20.

mynode.NodeFont = new System.Drawing.Font("Consolas", 9,FontStyle.Regular);

string displaytext = String.Format(CultureInfo.InvariantCulture, "{0}{2} = {1}", mystringOfDifferentLenght, myresult, GetEmptyInfoByIndex(mystringOfDifferentLength, 20));
mynode.Text = displaytext;
rootnode.Nodes.Add(mynode);

private string GetEmptyInfoByIndex(string _string, int maxLength)
    {
        string retstr = string.Empty;
        for (int i = 0; i < maxLength - _string.Length; i++)
        {
            retstr += " ";
        }
        return retstr;
    }

The proof is here!

0
source

All Articles