We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Change Multi-column Treeview cell border and alternate row color

I am using Multi-column treeview. I would like to change my border like spread sheet (continuous solid lines). I also want to set alternate row color. I am using VB.NET 2010.

What I am getting now is below:


What I like is below


Please help me solve this issue. Thank you.

Sincerely
Amirtharaj VK

3 Replies

SK Senthil Kumaran Rajan Syncfusion Team January 5, 2017 11:06 AM UTC

Hi Amirtharaj, 
 
Thanks for contacting Syncfusion Support. 
 
We can draw the border for the Nodes in MultiColumnTreeViewAdv, by handling the BeforePaint event. And the border of the SubItems can be customized by using the properties named BorderColor, BorderSides, BorderSingle and BorderStyle. Please make use of the below code example. 
 
Code Example[VB]: 
 
'To Paint border for nodes 
Private Sub multiColumnTreeView1_BeforeNodePaint(ByVal sender As Object, ByVal e As TreeNodeAdvPaintEventArgs) 
e.Graphics.DrawLine(Pens.Red, New Point(0, e.Node.Bounds.Y), New Point(Me.multiColumnTreeView1.Width,e.Node.Bounds.Y)) 
End Sub 
'To Paint border for sub nodes. 
For i As Integer = 0 To Me.multiColumnTreeView1.Nodes.Count - 1 
 
  For j As Integer = 1 To Me.multiColumnTreeView1.Nodes(i).SubItems.Count - 1 
    Me.multiColumnTreeView1.Nodes(i).SubItems(j).BorderColor = Color.Red 
    Me.multiColumnTreeView1.Nodes(i).SubItems(j).BorderSingle =        System.Windows.Forms.ButtonBorderStyle.Solid 
    Me.multiColumnTreeView1.Nodes(i).SubItems(j).BorderStyle = BorderStyle.FixedSingle 
    Me.multiColumnTreeView1.Nodes(i).SubItems(j).BorderSides = Border3DSide.Top 
  Next j 
Next i 
'Alternate row color. 
For i As Integer = 0 To Me.multiColumnTreeView1.Nodes.Count - 1 
If i Mod 2 <> 0 Then 
Me.multiColumnTreeView1.Nodes(i).Background = New Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.None, System.Drawing.SystemColors.WindowText, System.Drawing.Color.FromArgb((CInt(Fix((CByte(0))))), (CInt(Fix((CByte(192))))), (CInt(Fix((CByte(0))))))) 
For j As Integer = 1 To Me.multiColumnTreeView1.Nodes(i).SubItems.Count - 1 
Me.multiColumnTreeView1.Nodes(i).SubItems(j).Background = New Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.None, System.Drawing.SystemColors.WindowText, System.Drawing.Color.FromArgb((CInt(Fix((CByte(0))))), (CInt(Fix((CByte(192))))), (CInt(Fix((CByte(0))))))) 
Next j 
End If 
Next i 
 
 
We have prepared the sample for your reference and this can be downloaded from the below location. 
 
 
Also, refer the below screenshot for further reference. 
 
 
 
Regards, 
Senthil 



AM Amirtharaj January 7, 2017 04:25 AM UTC

Hi Senthil:

Thanks for your help. I will try and give the feedback.

Sincerely
Amirtharaj VK


SK Senthil Kumaran Rajan Syncfusion Team January 9, 2017 03:51 AM UTC

Hi Amirtharaj,

Thank you for your update.

We will wait until we hear from you.

Regards,
Senthil.

Loader.
Up arrow icon