我为每个TreeView节点实现了一个多色系统.但每次我展开一个子节点时,它都会消耗,但也会在我的rootNode上绘制节点(图像2和3).代码来自我之前的问题,这就是bug的样子

如果我决定关闭每个节点并重新扩展毛刺消失了.(图4)
问题似乎与Bounds这就是为什么平局不在正确的地方.知道为什么吗?
private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
string[] texts = e.Node.Text.Split();
using (Font font = new Font(this.Font, FontStyle.Regular))
{
using (Brush brush = new SolidBrush(Color.Red))
{
e.Graphics.DrawString(texts[0], font, brush, e.Bounds.Left, e.Bounds.Top);
}
using (Brush brush = new SolidBrush(Color.Blue))
{
SizeF s = e.Graphics.MeasureString(texts[0], font);
e.Graphics.DrawString(texts[1], font, brush, e.Bounds.Left + (int)s.Width, e.Bounds.Top);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我需要让TreeView中的节点内的文本在单词或字符中着色.那可能吗?怎么走?我听说过Custom Drawing但没有经验!