DataGridViewAdvancedBorderStyle DataGridViewAdvancedBorderStyle DataGridViewAdvancedBorderStyle DataGridViewAdvancedBorderStyle Class

정의

DataGridView 컨트롤의 셀 테두리 스타일을 포함합니다.Contains border styles for the cells in a DataGridView control.

public ref class DataGridViewAdvancedBorderStyle sealed : ICloneable
public sealed class DataGridViewAdvancedBorderStyle : ICloneable
type DataGridViewAdvancedBorderStyle = class
    interface ICloneable
Public NotInheritable Class DataGridViewAdvancedBorderStyle
Implements ICloneable
상속
DataGridViewAdvancedBorderStyleDataGridViewAdvancedBorderStyleDataGridViewAdvancedBorderStyleDataGridViewAdvancedBorderStyle
구현

예제

셀 테두리를 조정 하는 다음 코드 예제는 DataGridView 이중 테두리가 행 및 열 머리글에서 내부 셀 및 왼쪽된 위 머리글 셀을 구분 되도록 합니다.The following code example adjusts the cell borders of a DataGridView so that a double border separates the interior cells and the top left header cell from the row and column headers. 이 샘플을 재정의 하는 방법에 설명 합니다 AdjustColumnHeaderBorderStyle, AdjustRowHeaderBorderStyle, 및 AdjustCellBorderStyle 메서드 및 AdjustedTopLeftHeaderBorderStyle 속성.This sample demonstrates how to override the AdjustColumnHeaderBorderStyle, AdjustRowHeaderBorderStyle, and AdjustCellBorderStyle methods, and the AdjustedTopLeftHeaderBorderStyle property. 이러한 멤버를 사용 하 여 DataGridViewAdvancedBorderStyle 개별 셀 테두리를 수정 하는 개체입니다.These members use DataGridViewAdvancedBorderStyle objects to modify individual cell borders.

using System;
using System.Drawing;
using System.Windows.Forms;

namespace DataGridViewAdvancedBorderStyleSample
{
    class Form1 : Form
    {
        [STAThreadAttribute()]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

        public Form1()
        {
            this.AutoSize = true;
            this.Controls.Add(new CustomDataGridView());
            this.Text = "DataGridView advanced border styles demo";
        }
    }

    public class CustomDataGridView : DataGridView
    {
        public CustomDataGridView()
        {
            this.RowTemplate = new DataGridViewCustomRow();
            this.Columns.Add(new DataGridViewCustomColumn());
            this.Columns.Add(new DataGridViewCustomColumn());
            this.Columns.Add(new DataGridViewCustomColumn());
            this.RowCount = 4;
            this.EnableHeadersVisualStyles = false;
            this.AutoSize = true;
        }

        public override DataGridViewAdvancedBorderStyle AdjustedTopLeftHeaderBorderStyle
        {
            get
            {
                DataGridViewAdvancedBorderStyle newStyle =
                    new DataGridViewAdvancedBorderStyle();
                newStyle.Top = DataGridViewAdvancedCellBorderStyle.None;
                newStyle.Left = DataGridViewAdvancedCellBorderStyle.None;
                newStyle.Bottom = DataGridViewAdvancedCellBorderStyle.Outset;
                newStyle.Right = DataGridViewAdvancedCellBorderStyle.OutsetDouble;
                return newStyle;
            }
        }

        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;
        }
    }

    public class DataGridViewCustomColumn : DataGridViewColumn
    {
        public DataGridViewCustomColumn()
        {
            this.CellTemplate = new DataGridViewCustomCell();
        }
    }

    public class DataGridViewCustomCell : DataGridViewTextBoxCell
    {
        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 class DataGridViewCustomRow : DataGridViewRow
    {
        public override DataGridViewAdvancedBorderStyle AdjustRowHeaderBorderStyle(
            DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStyleInput,
            DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceHolder,
            bool singleVerticalBorderAdded,
            bool singleHorizontalBorderAdded,
            bool isFirstDisplayedRow,
            bool isLastDisplayedRow)
        {
            // Customize the top border of the first row header and the
            // right border of all the row headers. Use the input style for 
            // all other borders.
            dataGridViewAdvancedBorderStylePlaceHolder.Top = isFirstDisplayedRow ?
                DataGridViewAdvancedCellBorderStyle.InsetDouble :
                DataGridViewAdvancedCellBorderStyle.None;
            dataGridViewAdvancedBorderStylePlaceHolder.Right =
                DataGridViewAdvancedCellBorderStyle.OutsetDouble;

            dataGridViewAdvancedBorderStylePlaceHolder.Left =
                dataGridViewAdvancedBorderStyleInput.Left;
            dataGridViewAdvancedBorderStylePlaceHolder.Bottom =
                dataGridViewAdvancedBorderStyleInput.Bottom;

            return dataGridViewAdvancedBorderStylePlaceHolder;
        }
    }
}
Imports System.Drawing
Imports System.Windows.Forms


Namespace DataGridViewAdvancedBorderStyleSample

    Class Form1
        Inherits Form

        <STAThreadAttribute()> _
        Public Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New Form1())
        End Sub

        Public Sub New()
            Me.AutoSize = True
            Me.Controls.Add(New CustomDataGridView())
            Me.Text = "DataGridView advanced border styles demo"
        End Sub
    End Class

    Public Class CustomDataGridView
        Inherits DataGridView

        Public Sub New()
            With Me
                .RowTemplate = New DataGridViewCustomRow()
                .Columns.Add(New DataGridViewCustomColumn())
                .Columns.Add(New DataGridViewCustomColumn())
                .Columns.Add(New DataGridViewCustomColumn())
                .RowCount = 4
                .EnableHeadersVisualStyles = False
                .AutoSize = True
            End With
        End Sub

        Public Overrides ReadOnly Property AdjustedTopLeftHeaderBorderStyle() _
            As DataGridViewAdvancedBorderStyle
            Get
                Dim newStyle As New DataGridViewAdvancedBorderStyle()
                With newStyle
                    .Top = DataGridViewAdvancedCellBorderStyle.None
                    .Left = DataGridViewAdvancedCellBorderStyle.None
                    .Bottom = DataGridViewAdvancedCellBorderStyle.Outset
                    .Right = DataGridViewAdvancedCellBorderStyle.OutsetDouble
                End With
                Return newStyle
            End Get
        End Property

        Public Overrides Function AdjustColumnHeaderBorderStyle( _
            ByVal dataGridViewAdvancedBorderStyleInput As DataGridViewAdvancedBorderStyle, _
            ByVal dataGridViewAdvancedBorderStylePlaceHolder As DataGridViewAdvancedBorderStyle, _
            ByVal firstDisplayedColumn As Boolean, ByVal lastVisibleColumn As Boolean) _
            As DataGridViewAdvancedBorderStyle

            ' 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.
            If firstDisplayedColumn Then
                dataGridViewAdvancedBorderStylePlaceHolder.Left = _
                    DataGridViewAdvancedCellBorderStyle.OutsetDouble
            Else
                dataGridViewAdvancedBorderStylePlaceHolder.Left = _
                    DataGridViewAdvancedCellBorderStyle.None
            End If

            With dataGridViewAdvancedBorderStylePlaceHolder
                .Bottom = DataGridViewAdvancedCellBorderStyle.Single
                .Right = dataGridViewAdvancedBorderStyleInput.Right
                .Top = dataGridViewAdvancedBorderStyleInput.Top
            End With

            Return dataGridViewAdvancedBorderStylePlaceHolder
        End Function
    End Class

    Public Class DataGridViewCustomColumn
        Inherits DataGridViewColumn

        Public Sub New()
            Me.CellTemplate = New DataGridViewCustomCell()
        End Sub
    End Class

    Public Class DataGridViewCustomCell
        Inherits DataGridViewTextBoxCell

        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

    Public Class DataGridViewCustomRow
        Inherits DataGridViewRow

        Public Overrides Function AdjustRowHeaderBorderStyle( _
            ByVal dataGridViewAdvancedBorderStyleInput As DataGridViewAdvancedBorderStyle, _
            ByVal dataGridViewAdvancedBorderStylePlaceHolder As DataGridViewAdvancedBorderStyle, _
            ByVal singleVerticalBorderAdded As Boolean, _
            ByVal singleHorizontalBorderAdded As Boolean, _
            ByVal isFirstDisplayedRow As Boolean, _
            ByVal isLastDisplayedRow As Boolean) As DataGridViewAdvancedBorderStyle

            ' Customize the top border of the first row header and the
            ' right border of all the row headers. Use the input style for 
            ' all other borders.
            If isFirstDisplayedRow Then
                dataGridViewAdvancedBorderStylePlaceHolder.Top = _
                    DataGridViewAdvancedCellBorderStyle.InsetDouble
            Else
                dataGridViewAdvancedBorderStylePlaceHolder.Top = _
                    DataGridViewAdvancedCellBorderStyle.None
            End If

            With dataGridViewAdvancedBorderStylePlaceHolder
                .Right = DataGridViewAdvancedCellBorderStyle.OutsetDouble
                .Left = dataGridViewAdvancedBorderStyleInput.Left
                .Bottom = dataGridViewAdvancedBorderStyleInput.Bottom
            End With

            Return dataGridViewAdvancedBorderStylePlaceHolder
        End Function
    End Class

End Namespace

설명

DataGridView 컨트롤을 사용 하면 완전히 셀과 머리글의 테두리를 포함 하 여 모양을 사용자 지정할 수 있습니다.The DataGridView control allows you to fully customize its appearance, including the borders of the cells and headers. 합니다 DataGridViewCellBorderStyle, ColumnHeadersBorderStyle, 및 RowHeadersBorderStyle 셀 테두리의 모양을 설정 하는 데 사용할 수 있는 속성입니다.The DataGridView has CellBorderStyle, ColumnHeadersBorderStyle, and RowHeadersBorderStyle properties that allow you to set the appearance of the cell border. 그러나 추가 테두리, 사용자 지정 해야 하는 경우는 DataGridViewAdvancedBorderStyle 클래스를 사용 하면 개별 양쪽 셀의 테두리의 스타일을 설정할 수 있습니다.However, if you need to further customize the borders, the DataGridViewAdvancedBorderStyle class allows you to set the style of the border on the individual sides of the cells. 합니다 Left, RightTop, 및 Bottom 속성의 DataGridViewAdvancedBorderStyle 각각 왼쪽, 오른쪽, 위쪽 및 아래쪽 테두리의 셀을 나타냅니다.The Left, Right, Top, and Bottom properties of DataGridViewAdvancedBorderStyle represent the left, right, top, and bottom border of a cell, respectively. 이러한 속성을 설정할 수 있습니다는 AdvancedCellBorderStyle, AdvancedColumnHeadersBorderStyle, AdvancedRowHeadersBorderStyle 의 속성을 DataGridView 셀 사이의 테두리에 대 한 다양 한 모양을 생성 합니다.You can set these properties on the AdvancedCellBorderStyle, AdvancedColumnHeadersBorderStyle, AdvancedRowHeadersBorderStyle properties of the DataGridView to produce various appearances for the borders between the cells.

생성자

DataGridViewAdvancedBorderStyle() DataGridViewAdvancedBorderStyle() DataGridViewAdvancedBorderStyle() DataGridViewAdvancedBorderStyle()

DataGridViewAdvancedBorderStyle 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the DataGridViewAdvancedBorderStyle class.

속성

All All All All

모든 셀 테두리의 테두리 스타일을 가져오거나 설정합니다.Gets or sets the border style for all of the borders of a cell.

Bottom Bottom Bottom Bottom

셀의 아래쪽 테두리에 대한 스타일을 가져오거나 설정합니다.Gets or sets the style for the bottom border of a cell.

Left Left Left Left

셀의 왼쪽 테두리에 대한 스타일을 가져옵니다.Gets the style for the left border of a cell.

Right Right Right Right

셀의 오른쪽 테두리에 대한 스타일을 가져옵니다.Gets the style for the right border of a cell.

Top Top Top Top

셀의 위쪽 테두리에 대한 스타일을 가져옵니다.Gets the style for the top border of a cell.

메서드

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정된 개체가 현재 DataGridViewAdvancedBorderStyle과 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current DataGridViewAdvancedBorderStyle.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

특정 형식에 대한 해시 함수 역할을 합니다.Serves as a hash function for a particular type.

GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

DataGridViewAdvancedBorderStyle를 나타내는 문자열을 반환합니다.Returns a string that represents the DataGridViewAdvancedBorderStyle.

명시적 인터페이스 구현

ICloneable.Clone() ICloneable.Clone() ICloneable.Clone() ICloneable.Clone()

현재 인스턴스의 복사본인 새 개체를 만듭니다.Creates a new object that is a copy of the current instance.

적용 대상

추가 정보