DataGridViewCell.AdjustCellBorderStyle(DataGridViewAdvancedBorderStyle, DataGridViewAdvancedBorderStyle, Boolean, Boolean, Boolean, Boolean) 方法

定义

根据指定条件修改输入单元格的边框样式。Modifies the input cell border style according to the specified criteria.

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,表示要修改的单元格边框样式。A DataGridViewAdvancedBorderStyle that represents the cell border style to modify.

dataGridViewAdvancedBorderStylePlaceholder
DataGridViewAdvancedBorderStyle

一个 DataGridViewAdvancedBorderStyle,用于存储对单元格边框样式的中间更改。A DataGridViewAdvancedBorderStyle that is used to store intermediate changes to the cell border style.

singleVerticalBorderAdded
Boolean

若要向单元格添加竖框线,则为 true;否则为 falsetrue to add a vertical border to the cell; otherwise, false.

singleHorizontalBorderAdded
Boolean

若要向单元格添加横框线,则为 true;否则为 falsetrue to add a horizontal border to the cell; otherwise, false.

isFirstDisplayedColumn
Boolean

如果宿主单元格位于第一个可见列中,则为 true;否则为 falsetrue if the hosting cell is in the first visible column; otherwise, false.

isFirstDisplayedRow
Boolean

如果宿主单元格位于第一个可见行中,则为 true;否则为 falsetrue if the hosting cell is in the first visible row; otherwise, false.

返回

示例

下面的代码示例演示如何重写 AdjustCellBorderStyle 方法以自定义单元格边框。The following code example demonstrates how to override the AdjustCellBorderStyle method to customize the borders of the cells. 此代码示例是为 DataGridViewAdvancedBorderStyle 类提供的更大示例的一部分。This code example is part of a larger example provided for the DataGridViewAdvancedBorderStyle class.

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 方法来确定单元格边框的外观。The DataGridView control internally calls the AdjustCellBorderStyle method to determine the appearance of the cell borders. DataGridView 控件通常使用 dataGridViewAdvancedBorderStyleInput 参数的 AdvancedCellBorderStyle 属性的值。The DataGridView control typically uses the value of the AdvancedCellBorderStyle property for the dataGridViewAdvancedBorderStyleInput parameter.

不支持将 DataGridViewAdvancedCellBorderStyle.OutsetPartial 值作为单元格的输入样式。The DataGridViewAdvancedCellBorderStyle.OutsetPartial value is not supported as an input style for cells.

继承者说明

如果要自定义单元格边框的外观,请重写此方法。Override this method if you want to customize the appearance of the cell borders.

适用于

另请参阅