Xceed Grid for WinForms v4.3 Documentation
Welcome to Xceed Grid for WinForms v4.3 / Task-Based Help / Appearance / How to hide/remove grid lines

In This Topic
    How to hide/remove grid lines
    In This Topic

    There are 2 ways to hide or remove the grid lines: Your first (and easiest) option is to set the GridLineColor and GridLineBackColor properties to Color.Transparent. Your second option is to create a class the derives from the DataCell class and override the Borders property to remove the grid lines completely.

    Demonstration

    The following example demonstrates how to hide the grid lines by setting the grid's GridLineColor and GridLineBackColor properties to Color.Transparent: 

    VB.NET Copy Code

    GridControl1.GridLineColor = Color.Transparent
    GridControl1.GridLineBackColor = Color.Transparent

    C# Copy Code

    gridControl1.GridLineColor = Color.Transparent;
    gridControl1.GridLineBackColor = Color.Transparent;

    The next example demonstrates how to derive from the DataCell class to override the Borders property and remove the grid lines completely. Keep in mind that you also need to create a class that derives from the DataRow class that will contain your custom cells.

    VB.NET Copy Code

    Public Class CustomDataCell
      Inherits DataCell 

    Protected Sub New ( ByVal template As CustomDataCell )
      MyBase.New( template )
    End Sub 

    Public Sub New( ByVal parentColumn As Column )
      MyBase.New( parentColumn )
    End Sub 

    Protected Overrides Function CreateInstance() As Cell
      Return New CustomDataCell( Me )
    End Function 

    Public Overrides ReadOnly Property Borders As Borders
      Get
        Return Borders.Empty
      End Get
    End Property

    End Class 

    Public Class CustomDataRow
      Inherits Xceed.Grid.DataRow 

    Public Sub New()
      MyBase.New()
    End Sub 

    Protected Sub New( ByVal template As CustomDataRow )
      MyBase.New( template )
    End Sub 

    Protected Overrides Function CreateCell( ByVal parentColumn As Column ) As Cell
      Return New CustomDataCell( parentColumn )
    End Function 

    Protected Overrides Function CreateInstance() As Row
      Return New CustomDataRow( Me )
    End Function

    End Class

    C# Copy Code

    public class CustomDataCell : DataCell
    {
      protected CustomDataCell( CustomDataCell template )
        : base( template ){}

      public CustomDataCell( Column parentColumn )
        : base( parentColumn ){}

      protected override Cell CreateInstance()
      {
        return new CustomDataCell( this );
      }

      public override Borders Borders
      {
        get{ return Borders.Empty; }
      }

    public class CustomDataRow : Xceed.Grid.DataRow
    {
      public CustomDataRow()
        : base(){}

      protected CustomDataRow( CustomDataRow template )
        : base( template ){}

      protected override Cell CreateCell( Column parentColumn )
      {
        return new CustomDataCell( parentColumn );
      }
     
      protected override Row CreateInstance()
      {
        return new CustomDataRow( this );
      }
    }

    In order to use your new DataRow and DataCell, you must assign a new instance of your custom DataRow class to the DataRowTemplate property of the grid:

    VB.NET Copy Code
    GridControl1.DataRowTemplate = new CustomDataRow()
    C# Copy Code
    gridControl1.DataRowTemplate = new CustomDataRow();