FlexGrid for WinForms | ComponentOne
Styling and Appearance / Customize Border
In This Topic
    Customize Border
    In This Topic

    The FlexGrid control lets you customize the border of grid, row, column and even cells by changing its style, color direction and so on.

    Customize Borders

    Customize Grid Border

    To customize border of the grid control, you can use the BorderStyle property which accepts values from BorderStyleEnum provided by the C1.Win.FlexGrid.Util.BaseControls namespace.

    Following code shows how to customize border of the WinForms FlexGrid control.

    // Change the grid border to a three dimensional border
    c1FlexGrid1.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Fixed3D;               
    
    ' Change the grid border to a three dimensional border
    c1FlexGrid1.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.Fixed3D              
    

    Customize Row/Column Border

    To customize the border style of a particular row or column, you must access the 'Border' item of CellStyle class using StyleNew property and set its properties such as border style, direction and color. The grid control provides BorderStyleEnum as well as BorderDirEnum to set the border style and direction respectively.

    Use the below code to change border of rows or columns of the WinForms FlexGrid.

    // Set the border style for first column
    c1FlexGrid1.Cols[1].StyleNew.Border.Style = BorderStyleEnum.Groove;
    c1FlexGrid1.Cols[1].StyleNew.Border.Color = Color.Red;
    c1FlexGrid1.Cols[1].StyleNew.Border.Direction = BorderDirEnum.Vertical;
    
    //Set the border style for first row
    c1FlexGrid1.Rows[1].StyleNew.Border.Style = BorderStyleEnum.Raised;
    c1FlexGrid1.Rows[1].StyleNew.Border.Color = Color.Blue;
    
    ' Set the border style for first column
    c1FlexGrid1.Cols(1).StyleNew.Border.Style = BorderStyleEnum.Groove
    c1FlexGrid1.Cols(1).StyleNew.Border.Color = Color.Red
    c1FlexGrid1.Cols(1).StyleNew.Border.Direction = BorderDirEnum.Vertical
    
    'Set the border style for first row
    c1FlexGrid1.Rows(1).StyleNew.Border.Style = BorderStyleEnum.Raised
    c1FlexGrid1.Rows(1).StyleNew.Border.Color = Color.Blue        
    

    Customize Cell Border

    To customize border of every cell in the grid, you can access the built-in style "Normal" and set its border properties. Similarly, you can change the style of specific types of cells such fixed or frozen by accessing their corresponding styles from Styles collection.

    Below code lets you customize the border of normal cells of the WinForms FlexGrid.

    // Set the border style for all grid cells
    c1FlexGrid1.Styles.Normal.Border.Style = BorderStyleEnum.Double; 
    
    ' Set the border style for all grid cells
    c1FlexGrid1.Styles.Normal.Border.Style = BorderStyleEnum.Double