Grid / Grid Features / Gridlines
In This Topic
    Gridlines
    In This Topic
     About Gridlines

    The gridlines are lines that are used to separate the grid rows and data cells, row headers and columns. The following image illustrates the gridlines:

    As you can see there are three objects that display gridlines:

    1. Grid Gridlines - the gridlines that separate the rows and data cells are displayed by each row and are global settings of the grid. The strokes for these gridlines are specified by the HorizontalGridlinesStroke and VerticalGridlinesStroke properties of the grid.
    2. Columns Gridlines - there are three types of gridlines that separate the grid columns - Top Gridline, Bottom Gridline and Vertical Columns Gridlines. The strokes for these gridlines are controlled by the TopGridlineStroke, BottomGridlineStroke and VerticalGridlinesStroke properties of the grid columns collection.
    3. Row Headers Gridlines - there are three types of gridlines that separate the grid row headers - Left Gridline, Right Gridline and Horizontal Columns Gridlines. The strokes for these gridlines are controlled by the TopGridlineStroke, BottomGridlineStroke and VerticalGridlinesStroke properties of the grid columns collection.
    The width of the gridlines is internally taken into account in the grid layout. Additionally gridlines are pixel snapped.
    For best visual quality it is recommended to use strokes with Start and End caps set to Flat.

     

     Grid Gridlines

    The grid displays uniform gridlines for rows and data cells. There are two types of gridlines that are used to separate rows and data cells - horizontal and vertical - the stroking of which is controlled by the HorizontalGridlinesStroke and VerticalGridlinesStroke properties of NGrid (base class for NTableGrid and NTreeGrid). The following code example alters the gridlines of the grid:

    Grid Gridlines Example
    Copy Code
    // style horizontal grid gridlines (width: 2, color: Red)
    NStroke hstroke = new NStroke(2, NColor.Red);
    hstroke.StartCap = ENLineCap.Flat;
    hstroke.EndCap = ENLineCap.Flat;
    grid.HorizontalGridlinesStroke = hstroke;
    // style vertical grid gridlines (width: 2, color: Blue)
    NStroke vstroke = new NStroke(2, NColor.Blue);
    vstroke.StartCap = ENLineCap.Flat;
    vstroke.EndCap = ENLineCap.Flat;
    grid.VerticalGridlinesStroke = vstroke;
    
    Unless explicitly specified the columns horizontal gridlines and the row headers vertical gridlines are automatically inherited by the horizontal and vertical gridlines of the grid.
     Columns Gridlines

    The columns display three gridlines that separate the column headers - top columns gridline, bottom columns gridline and vertical columns gridlines, that are controlled by TopGridlineStroke, BottomGridlineStroke and VerticalGridlinesStroke properties of the grid columns collection. The following example alters the gridlines of the columns:

    Column Gridlines Example
    Copy Code
    // style top columns gridline (width: 2, color: Red)
    NStroke topstroke = new NStroke(2, NColor.Red);
    topstroke.StartCap = ENLineCap.Flat;
    topstroke.EndCap = ENLineCap.Flat;
    grid.Columns.TopGridlineStroke = topstroke;
    // style bottom columns gridline (width: 2, color: Blue)
    NStroke bottomstroke = new NStroke(2, NColor.Blue);
    bottomstroke.StartCap = ENLineCap.Flat;
    bottomstroke.EndCap = ENLineCap.Flat;
    grid.Columns.BottomGridlineStroke = bottomstroke;
    // style bottom columns gridline (width: 2, color: Yellow)
    NStroke vstroke = new NStroke(2, NColor.Yellow);
    vstroke.StartCap = ENLineCap.Flat;
    vstroke.EndCap = ENLineCap.Flat;
    grid.Columns.VerticalGridlinesStroke = vstroke;
    
    If not explicitly specified the vertical gridlines are inherited by the grid vertical gridlines.
     Row Headers Gridlines

    The row headers three gridlines that separate the row headers - left row headers gridline, right row headers gridline and horizontal row headers gridlines, that are controlled by LeftGridlineStroke, RightGridlineStroke and HorizontalGridlinesStroke properties of the grid columns collection. The following example alters the gridlines of the columns:

    Row Headers Gridlines Example
    Copy Code
    // style top columns gridline (width: 2, color: Red)
    NStroke leftstroke = new NStroke(2, NColor.Red);
    leftstroke.StartCap = ENLineCap.Flat;
    leftstroke.EndCap = ENLineCap.Flat;
    grid.RowHeaders.LeftGridlineStroke = leftstroke;
    // style bottom columns gridline (width: 2, color: Blue)
    NStroke rightstroke = new NStroke(2, NColor.Blue);
    rightstroke.StartCap = ENLineCap.Flat;
    rightstroke.EndCap = ENLineCap.Flat;
    grid.RowHeaders.RightGridlineStroke = rightstroke;
    // style bottom columns gridline (width: 2, color: Yellow)
    NStroke hstroke = new NStroke(2, NColor.Yellow);
    hstroke.StartCap = ENLineCap.Flat;
    hstroke.EndCap = ENLineCap.Flat;
    grid.RowHeaders.HorizontalGridlinesStroke = hstroke;
    
    If not explicitly specified the horizontal gridlines are inherited by the grid horizontal gridlines.