Articles in this section
Category / Section

How to draw only focus rectangle when selecting multiple nodes without displaying highlighting colors in WinForms TreeViewAdv?

1 min read

Select the multiple nodes without highlighting colors

Displaying only focus rectangle when selecting multiple nodes without displaying highlighting colors can be acheived by setting the SelectedNodeBackground property's value to Color.Transparent and drawing the focus rectangle in SelectedNodeBackground event.


this.treeViewAdv1.SelectedNodeBackground = new Syncfusion.Drawing.BrushInfo(Color.Transparent);
void treeViewAdv1_NodeBackgroundPaint(object sender, TreeNodeAdvPaintBackgroundEventArgs e)
      foreach(TreeNodeAdv treenode in treeViewAdv1.SelectedNodes)
         using (Pen focusPen = new Pen(Color.Black))
             focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
             Rectangle focusBounds = treenode.DragCueBounds;
             focusBounds.Size = new Size(focusBounds.Width - 1, focusBounds.Height-1);
             e.Graphics.DrawRectangle(focusPen, focusBounds);


Me.treeViewAdv1.SelectedNodeBackground = New Syncfusion.Drawing.BrushInfo(Color.Transparent)
Private Sub treeViewAdv1_NodeBackgroundPaint(ByVal sender As Object, ByVal e As TreeNodeAdvPaintBackgroundEventArgs)
   If Me.treeViewAdv1.SelectedNodes.Count<>0 Then
      For Each treenode As TreeNodeAdv In treeViewAdv1.SelectedNodes
          Using focusPen As Pen = New Pen(Color.Black)
              focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot
              Dim focusBounds As Rectangle = treenode.DragCueBounds
              focusBounds.Size = New Size(focusBounds.Width - 1, focusBounds.Height-1)
              e.Graphics.DrawRectangle(focusPen, focusBounds)
          End Using
      Next treenode
   End If
End Sub


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment