Having difficulty understanding treeview treeview, here is the full story:
VS2013 WinForms application (works in Windows 8.1 with TrueType enabled, if that matters ...) with a tree using: DrawMode = OwnerDrawText;
When the form loads, some nodes are added to the tree:
private void Form1_Load(object sender, EventArgs e) {
Next, I draw the entire node myself to show the problem:
private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e) { // use ownerdraw every other item if ((int)(e.Node.Tag) % 2 == 0) { Font font = e.Node.NodeFont; if (font == null) font = e.Node.TreeView.Font; e.Graphics.DrawString(e.Node.Text, font, Brushes.Red, e.Bounds.X, e.Bounds.Y); } else { e.DrawDefault = true; } }
Look at the results, pay attention to the fact that the nodes of the owner (red) of the elements have an intersymbol spacing different from when the tree structure draws its own nodes. And after some time, the interval will suddenly change. Am I using the wrong font here? Am I missing something?
Thank you for your time.
source share