SoFunction
Updated on 2025-03-07

Custom drawing method of TreeView node in C#

This article describes the custom drawing method of TreeView node in C#. Share it for your reference. The details are as follows:

if (( & ) != 0)
{
 //Demonstrate as a white character on green background (, );

 Font nodeFont = ;
 if (nodeFont == null) nodeFont = ((TreeView)sender).Font;
 (, nodeFont, , (, 2, 0));
}
else
{
  = true;
}

if (( & ) != 0)
{
 using (Pen focusPen = new Pen())
 {
   = .;
  Rectangle focusBounds = ;
   = new Size( - 1,
   - 1);
  (focusPen, focusBounds);
 }
}

I hope this article will be helpful to everyone's C# programming.