DataGridView.CellBorderStyle 속성


DataGridView의 셀 테두리 스타일을 가져옵니다.Gets the cell border style for the DataGridView.

 property System::Windows::Forms::DataGridViewCellBorderStyle CellBorderStyle { System::Windows::Forms::DataGridViewCellBorderStyle get(); void set(System::Windows::Forms::DataGridViewCellBorderStyle value); };
public System.Windows.Forms.DataGridViewCellBorderStyle CellBorderStyle { get; set; }
member this.CellBorderStyle : System.Windows.Forms.DataGridViewCellBorderStyle with get, set
Public Property CellBorderStyle As DataGridViewCellBorderStyle

속성 값

DataGridView에 포함된 셀의 테두리 스타일을 나타내는 DataGridViewCellBorderStyle입니다.A DataGridViewCellBorderStyle that represents the border style of the cells contained in the DataGridView.



이 속성을 설정할 때 지정된 값이 유효한 DataGridViewCellBorderStyle 값이 아닙니다.The specified value when setting this property is not a valid DataGridViewCellBorderStyle value.

이 속성을 설정할 때 지정된 값이 Custom입니다.The specified value when setting this property is Custom.


다음 코드 예제를 사용 하는 방법에 설명 합니다 CellBorderStyle 속성입니다.The following code example demonstrates how to use the CellBorderStyle property. 이 예제를 실행 하려면 코드를 포함 하는 폼에 붙여 넣습니다를 DataGridView 라는 dataGridView1, 다음 호출 합니다 SetUpDataGridView 폼의 생성자에서 메서드 또는 Load 이벤트 처리기입니다.To run this example, paste the code into a form that contains a DataGridView named dataGridView1, and then call the SetUpDataGridView method from the form's constructor or Load event handler. 모든 이벤트가 해당 이벤트 처리기와 연결 되도록 합니다.Ensure all events are associated with their event handlers.

void SetUpDataGridView()
   this->Controls->Add( dataGridView1 );
   dataGridView1->ColumnCount = 5;
   DataGridViewCellStyle^ style = dataGridView1->ColumnHeadersDefaultCellStyle;
   style->BackColor = Color::Navy;
   style->ForeColor = Color::White;
   style->Font = gcnew System::Drawing::Font( dataGridView1->Font,FontStyle::Bold );
   dataGridView1->EditMode = DataGridViewEditMode::EditOnEnter;
   dataGridView1->Name = "dataGridView1";
   dataGridView1->Location = Point(8,8);
   dataGridView1->Size = System::Drawing::Size( 500, 300 );
   dataGridView1->AutoSizeRowsMode = DataGridViewAutoSizeRowsMode::DisplayedCellsExceptHeaders;
   dataGridView1->ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle::Raised;
   dataGridView1->CellBorderStyle = DataGridViewCellBorderStyle::Single;
   dataGridView1->GridColor = SystemColors::ActiveBorder;
   dataGridView1->RowHeadersVisible = false;
   dataGridView1->Columns[ 0 ]->Name = "Release Date";
   dataGridView1->Columns[ 1 ]->Name = "Track";
   dataGridView1->Columns[ 1 ]->DefaultCellStyle->Alignment = DataGridViewContentAlignment::MiddleCenter;
   dataGridView1->Columns[ 2 ]->Name = "Title";
   dataGridView1->Columns[ 3 ]->Name = "Artist";
   dataGridView1->Columns[ 4 ]->Name = "Album";

   // Make the font italic for row four.
   dataGridView1->Columns[ 4 ]->DefaultCellStyle->Font = gcnew System::Drawing::Font( DataGridView::DefaultFont,FontStyle::Italic );
   dataGridView1->SelectionMode = DataGridViewSelectionMode::FullRowSelect;
   dataGridView1->MultiSelect = false;
   dataGridView1->BackgroundColor = Color::Honeydew;
   dataGridView1->Dock = DockStyle::Fill;
   dataGridView1->CellFormatting += gcnew DataGridViewCellFormattingEventHandler( this, &Form1::dataGridView1_CellFormatting );
   dataGridView1->CellParsing += gcnew DataGridViewCellParsingEventHandler( this, &Form1::dataGridView1_CellParsing );
   addNewRowButton->Click += gcnew EventHandler( this, &Form1::addNewRowButton_Click );
   deleteRowButton->Click += gcnew EventHandler( this, &Form1::deleteRowButton_Click );
   ledgerStyleButton->Click += gcnew EventHandler( this, &Form1::ledgerStyleButton_Click );
   dataGridView1->CellValidating += gcnew DataGridViewCellValidatingEventHandler( this, &Form1::dataGridView1_CellValidating );
private void SetUpDataGridView()
    dataGridView1.ColumnCount = 5;
    DataGridViewCellStyle style = 
    style.BackColor = Color.Navy;
    style.ForeColor = Color.White;
    style.Font = new Font(dataGridView1.Font, FontStyle.Bold);

    dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
    dataGridView1.Name = "dataGridView1";
    dataGridView1.Location = new Point(8, 8);
    dataGridView1.Size = new Size(500, 300);
    dataGridView1.AutoSizeRowsMode = 
    dataGridView1.ColumnHeadersBorderStyle = 
    dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.Single;
    dataGridView1.GridColor = SystemColors.ActiveBorder;
    dataGridView1.RowHeadersVisible = false;

    dataGridView1.Columns[0].Name = "Release Date";
    dataGridView1.Columns[1].Name = "Track";
    dataGridView1.Columns[1].DefaultCellStyle.Alignment = 
    dataGridView1.Columns[2].Name = "Title";
    dataGridView1.Columns[3].Name = "Artist";
    dataGridView1.Columns[4].Name = "Album";

    // Make the font italic for row four.
    dataGridView1.Columns[4].DefaultCellStyle.Font = new Font(DataGridView.DefaultFont, FontStyle.Italic);

    dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    dataGridView1.MultiSelect = false;

    dataGridView1.BackgroundColor = Color.Honeydew;

    dataGridView1.Dock = DockStyle.Fill;

    dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
    dataGridView1.CellParsing += new DataGridViewCellParsingEventHandler(dataGridView1_CellParsing);
    addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
    deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
    ledgerStyleButton.Click += new EventHandler(ledgerStyleButton_Click);
    dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);

Private Sub SetUpDataGridView()

    dataGridView1.ColumnCount = 5

    With dataGridView1.ColumnHeadersDefaultCellStyle
        .BackColor = Color.Navy
        .ForeColor = Color.White
        .Font = New Font(dataGridView1.Font, FontStyle.Bold)
    End With

    With dataGridView1
        .EditMode = DataGridViewEditMode.EditOnEnter
        .Name = "dataGridView1"
        .Location = New Point(8, 8)
        .Size = New Size(500, 300)
        .AutoSizeRowsMode = _
        .ColumnHeadersBorderStyle = _
        .CellBorderStyle = _
        .GridColor = SystemColors.ActiveBorder
        .RowHeadersVisible = False

        .Columns(0).Name = "Release Date"
        .Columns(1).Name = "Track"
        .Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        .Columns(2).Name = "Title"
        .Columns(3).Name = "Artist"
        .Columns(4).Name = "Album"

        ' Make the font italic for row four.
        .Columns(4).DefaultCellStyle.Font = _
            New Font(Control.DefaultFont, _

        .SelectionMode = _
        .MultiSelect = False

        .BackgroundColor = Color.Honeydew

        .Dock = DockStyle.Fill
    End With

End Sub


경우는 CellBorderStyle 속성이 아닌 다른 값으로 설정 되어 Single, SingleHorizontal, 또는 SingleVerticalGridColor 속성 시스템 색 이어야 합니다.If the CellBorderStyle property is set to anything other than Single, SingleHorizontal, or SingleVertical, the GridColor property must be a system color.

이 속성 설정할 수 없습니다는 Custom 는 읽기 전용으로 지정 하는 값 셀 테두리 스타일을 사용 하 여 사용자 지정 된 값을 AdvancedCellBorderStyle 속성입니다.You cannot set this property to the Custom value, which is a read-only value indicating that the cell border style has been customized through the use of the AdvancedCellBorderStyle property.

적용 대상

추가 정보