Skip to content

SyncfusionExamples/How-to-seperate-background-between-two-nodes-in-WF-TreeViewAdv

Repository files navigation

How to separate background between two adjacent nodes in WinForms TreeViewAdv?

You can separate the background between two adjacent nodes in WinForms TreeViewAdv control by using BeforeNodePaint event. Refer the below code for your reference.

C#

treeViewAdv1.BeforeNodePaint += TreeViewAdv1_BeforeNodePaint1;
 
//Customize Background of Nodes
private void TreeViewAdv1_BeforeNodePaint1(object sender, TreeNodeAdvPaintEventArgs e)
{
   LinearGradientBrush lBrush = new LinearGradientBrush(e.Node.Bounds, Color.LightGreen, Color.LightSeaGreen, LinearGradientMode.Horizontal);
   e.Graphics.FillRectangle(lBrush, e.Node.Bounds);
   e.Graphics.DrawRectangle(new Pen(Color.Red), e.Node.Bounds);
}

VB.Net

AddHandler treeViewAdv1.BeforeNodePaint, AddressOf TreeViewAdv1_BeforeNodePaint1

'Customize Background of Nodes
Private Sub TreeViewAdv1_BeforeNodePaint1(ByVal sender As Object, ByVal e As TreeNodeAdvPaintEventArgs)
    Dim lBrush As New LinearGradientBrush(e.Node.Bounds, Color.LightGreen, Color.LightSeaGreen, LinearGradientMode.Horizontal)
    e.Graphics.FillRectangle(lBrush, e.Node.Bounds)
    e.Graphics.DrawRectangle(New Pen(Color.Red), e.Node.Bounds)
End Sub

Background between adjacent nodes

About

This respository contains the sample that how to seperate the background between two nodes in WF TreeViewAdv control.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5