DataGridView.AdjustColumnHeaderBorderStyle Method

Definition

Adjusts the DataGridViewAdvancedBorderStyle for a column header cell of a DataGridView that is currently being painted.

C#
public virtual System.Windows.Forms.DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle(System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool isFirstDisplayedColumn, bool isLastVisibleColumn);

Parameters

dataGridViewAdvancedBorderStyleInput
DataGridViewAdvancedBorderStyle

A DataGridViewAdvancedBorderStyle that represents the column header border style to modify.

dataGridViewAdvancedBorderStylePlaceholder
DataGridViewAdvancedBorderStyle

A DataGridViewAdvancedBorderStyle that is used to store intermediate changes to the column header border style.

isFirstDisplayedColumn
Boolean

true to indicate that the DataGridViewCell that is currently being painted is in the first column displayed on the DataGridView; otherwise, false.

isLastVisibleColumn
Boolean

true to indicate that the DataGridViewCell that is currently being painted is in the last column in the DataGridView that has the Visible property set to true; otherwise, false.

Returns

A DataGridViewAdvancedBorderStyle that represents the border style for the current column header.

Examples

The following code example demonstrates how to override the AdjustColumnHeaderBorderStyle method to customize the borders of the column header cells. This code example is part of a larger example provided for the DataGridViewAdvancedBorderStyle class.

C#
public override DataGridViewAdvancedBorderStyle AdjustColumnHeaderBorderStyle(
    DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
    DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
    bool firstDisplayedColumn,
    bool lastVisibleColumn)
{
    // Customize the left border of the first column header and the
    // bottom border of all the column headers. Use the input style for 
    // all other borders.
    dataGridViewAdvancedBorderStylePlaceHolder.Left = firstDisplayedColumn ?
        DataGridViewAdvancedCellBorderStyle.OutsetDouble :
        DataGridViewAdvancedCellBorderStyle.None;
    dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
        DataGridViewAdvancedCellBorderStyle.Single;

    dataGridViewAdvancedBorderStylePlaceHolder.Right =
        dataGridViewAdvancedBorderStyleInput.Right;
    dataGridViewAdvancedBorderStylePlaceHolder.Top =
        dataGridViewAdvancedBorderStyleInput.Top;

    return dataGridViewAdvancedBorderStylePlaceHolder;
}

Remarks

The DataGridView control internally calls the AdjustColumnHeaderBorderStyle method to determine the appearance of the borders for the column header cells. The DataGridView control typically uses the value of the AdvancedColumnHeadersBorderStyle property for the dataGridViewAdvancedBorderStyleInput parameter.

Notes to Inheritors

Override this method if you want to customize the appearance of the border on column header cells.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also