вверху:
Код: Выделить всё
public partial class CustomFolderBrowser : Form
{
private TreeView folderTreeView;
private Button okButton;
private Button cancelButton;
private Button makeNewFolderButton;
private BufferedLabel feedbackLabel;
private Image expandIcon;
private Image collapseIcon;
public string SelectedPath { get; private set; }
Код: Выделить всё
private void FolderTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
// Get the bounds of the node
Rectangle nodeRect = e.Node.Bounds;
// Clear the icon area before redrawing
e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds); // Clear previous drawing
/*--------- 1. Draw expand/collapse icon ---------*/
if (e.Node.Nodes.Count > 0)
{
// Calculate position for expand/collapse icon
Point ptExpand = new Point(nodeRect.Left - 16, nodeRect.Top + (nodeRect.Height - 16) / 2); // Align vertically
// Choose the appropriate icon
Image expandCollapseImg = e.Node.IsExpanded ? collapseIcon : expandIcon;
// Draw the icon (ensure it is redrawn over a clear background)
e.Graphics.DrawImage(expandCollapseImg, ptExpand);
}
/*--------- 2. Draw node text ---------*/
// Get the node's font (default if none is set)
Font nodeFont = e.Node.NodeFont ?? ((TreeView)sender).Font;
// Set the color for the text (highlight if selected)
Brush textBrush = SystemBrushes.WindowText;
if ((e.State & TreeNodeStates.Selected) != 0)
{
textBrush = SystemBrushes.HighlightText;
e.Graphics.FillRectangle(SystemBrushes.Highlight, nodeRect); // Highlight background
}
// Draw the text
e.Graphics.DrawString(e.Node.Text, nodeFont, textBrush, nodeRect);
// Draw focus rectangle if node is selected
if ((e.State & TreeNodeStates.Focused) != 0)
{
ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
}
}

и здесь я отметил артефакты справа красными кружками

Подробнее здесь: https://stackoverflow.com/questions/790 ... cts-betwee