DataGridViewCell.AdjustCellBorderStyle 方法

定义

根据指定条件修改输入单元格的边框样式。

public:
 virtual System::Windows::Forms::DataGridViewAdvancedBorderStyle ^ AdjustCellBorderStyle(System::Windows::Forms::DataGridViewAdvancedBorderStyle ^ dataGridViewAdvancedBorderStyleInput, System::Windows::Forms::DataGridViewAdvancedBorderStyle ^ dataGridViewAdvancedBorderStylePlaceholder, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow);
public virtual System.Windows.Forms.DataGridViewAdvancedBorderStyle AdjustCellBorderStyle (System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput, System.Windows.Forms.DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow);
abstract member AdjustCellBorderStyle : System.Windows.Forms.DataGridViewAdvancedBorderStyle * System.Windows.Forms.DataGridViewAdvancedBorderStyle * bool * bool * bool * bool -> System.Windows.Forms.DataGridViewAdvancedBorderStyle
override this.AdjustCellBorderStyle : System.Windows.Forms.DataGridViewAdvancedBorderStyle * System.Windows.Forms.DataGridViewAdvancedBorderStyle * bool * bool * bool * bool -> System.Windows.Forms.DataGridViewAdvancedBorderStyle
Public Overridable Function AdjustCellBorderStyle (dataGridViewAdvancedBorderStyleInput As DataGridViewAdvancedBorderStyle, dataGridViewAdvancedBorderStylePlaceholder As DataGridViewAdvancedBorderStyle, singleVerticalBorderAdded As Boolean, singleHorizontalBorderAdded As Boolean, isFirstDisplayedColumn As Boolean, isFirstDisplayedRow As Boolean) As DataGridViewAdvancedBorderStyle

参数

dataGridViewAdvancedBorderStyleInput
DataGridViewAdvancedBorderStyle

一个 DataGridViewAdvancedBorderStyle,表示要修改的单元格边框样式。

dataGridViewAdvancedBorderStylePlaceholder
DataGridViewAdvancedBorderStyle

一个 DataGridViewAdvancedBorderStyle,用于存储对单元格边框样式的中间更改。

singleVerticalBorderAdded
Boolean

若要向单元格添加竖框线,则为 true;否则为 false

singleHorizontalBorderAdded
Boolean

若要向单元格添加横框线,则为 true;否则为 false

isFirstDisplayedColumn
Boolean

如果宿主单元格位于第一个可见列中,则为 true;否则为 false

isFirstDisplayedRow
Boolean

如果宿主单元格位于第一个可见行中,则为 true;否则为 false

返回

DataGridViewAdvancedBorderStyle

所修改的 DataGridViewAdvancedBorderStyle

示例

下面的代码示例演示如何重写 AdjustCellBorderStyle 方法以自定义单元格的边框。 此代码示例是为 DataGridViewAdvancedBorderStyle 类提供的一个更大示例的一部分。

public override DataGridViewAdvancedBorderStyle AdjustCellBorderStyle(
    DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
    DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
    bool singleVerticalBorderAdded,
    bool singleHorizontalBorderAdded,
    bool firstVisibleColumn,
    bool firstVisibleRow)
{
    // Customize the top border of cells in the first row and the 
    // right border of cells in the first column. Use the input style 
    // for all other borders.
    dataGridViewAdvancedBorderStylePlaceHolder.Left = firstVisibleColumn ?
        DataGridViewAdvancedCellBorderStyle.OutsetDouble :
        DataGridViewAdvancedCellBorderStyle.None;
    dataGridViewAdvancedBorderStylePlaceHolder.Top = firstVisibleRow ?
        DataGridViewAdvancedCellBorderStyle.InsetDouble :
        DataGridViewAdvancedCellBorderStyle.None;

    dataGridViewAdvancedBorderStylePlaceHolder.Right =
        dataGridViewAdvancedBorderStyleInput.Right;
    dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
        dataGridViewAdvancedBorderStyleInput.Bottom;

    return dataGridViewAdvancedBorderStylePlaceHolder;
}
    Public Overrides Function AdjustCellBorderStyle( _
        ByVal dataGridViewAdvancedBorderStyleInput As DataGridViewAdvancedBorderStyle, _
        ByVal dataGridViewAdvancedBorderStylePlaceHolder As DataGridViewAdvancedBorderStyle, _
        ByVal singleVerticalBorderAdded As Boolean, _
        ByVal singleHorizontalBorderAdded As Boolean, _
        ByVal firstVisibleColumn As Boolean, _
        ByVal firstVisibleRow As Boolean) As DataGridViewAdvancedBorderStyle

        ' Customize the top border of cells in the first row and the 
        ' right border of cells in the first column. Use the input style 
        ' for all other borders.
        If firstVisibleColumn Then
            dataGridViewAdvancedBorderStylePlaceHolder.Left = _
                DataGridViewAdvancedCellBorderStyle.OutsetDouble
        Else
            dataGridViewAdvancedBorderStylePlaceHolder.Left = _
                DataGridViewAdvancedCellBorderStyle.None
        End If

        If firstVisibleRow Then
            dataGridViewAdvancedBorderStylePlaceHolder.Top = _
                DataGridViewAdvancedCellBorderStyle.InsetDouble
        Else
            dataGridViewAdvancedBorderStylePlaceHolder.Top = _
                DataGridViewAdvancedCellBorderStyle.None
        End If

        With dataGridViewAdvancedBorderStylePlaceHolder
            .Right = dataGridViewAdvancedBorderStyleInput.Right
            .Bottom = dataGridViewAdvancedBorderStyleInput.Bottom
        End With

        Return dataGridViewAdvancedBorderStylePlaceHolder
    End Function
End Class

注解

控件 DataGridView 在内部调用 AdjustCellBorderStyle 该方法以确定单元格边框的外观。 该DataGridView控件通常使用dataGridViewAdvancedBorderStyleInput参数的属性AdvancedCellBorderStyle值。

不支持该值 DataGridViewAdvancedCellBorderStyle.OutsetPartial 作为单元格的输入样式。

继承者说明

如果要自定义单元格边框的外观,请重写此方法。

适用于

另请参阅