Home › Forums › WinForms controls › Xceed Grid for WinForms › How to hide or remove grid lines
-
AuthorPosts
-
#17808 |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.
The following example demonstrates how to hide the grid lines by setting the grid’s GridLineColor and GridLineBackColor properties to Color.Transparent:
VB.NET
GridControl1.GridLineColor = Color.Transparent
GridControl1.GridLineBackColor = Color.TransparentC#
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
Public Class CustomDataCell
Inherits DataCellProtected Sub New ( ByVal template As CustomDataCell )
MyBase.New( template )
End SubPublic Sub New( ByVal parentColumn As Column )
MyBase.New( parentColumn )
End SubProtected Overrides Function CreateInstance() As Cell
Return New CustomDataCell( Me )
End FunctionPublic Overrides ReadOnly Property Borders As Borders
Get
Return Borders.Empty
End Get
End Property
End ClassPublic Class CustomDataRow
Inherits Xceed.Grid.DataRowPublic Sub New()
MyBase.New()
End SubProtected Sub New( ByVal template As CustomDataRow )
MyBase.New( template )
End SubProtected Overrides Function CreateCell( ByVal parentColumn As Column ) As Cell
Return New CustomDataCell( parentColumn )
End FunctionProtected Overrides Function CreateInstance() As Row
Return New CustomDataRow( Me )
End Function
End ClassC#
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 GridControl1.DataRowTemplate = New CustomDataRow()
C#
gridControl1.DataRowTemplate = new CustomDataRow();Imported from legacy forums. Posted by Xceed admin (had 1636 views)
-
AuthorPosts
- You must be logged in to reply to this topic.