DataGridViewRow.Cells 속성

정의

행을 채우는 셀의 컬렉션을 가져옵니다.

public:
 property System::Windows::Forms::DataGridViewCellCollection ^ Cells { System::Windows::Forms::DataGridViewCellCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.DataGridViewCellCollection Cells { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Cells : System.Windows.Forms.DataGridViewCellCollection
Public ReadOnly Property Cells As DataGridViewCellCollection

속성 값

DataGridViewCellCollection

행의 셀을 모두 포함하는 DataGridViewCellCollection입니다.

특성

예제

다음 코드 예제에서는 속성을 사용하여 Cells 행에 있는 셀의 값을 설정합니다. 이 코드 예제는 방법: Windows Forms DataGridView 컨트롤의 행 조작에 제공된 더 큰 코드 예제의 일부입니다.

// Give cheescake excellent rating.
void Button8_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   UpdateStars( dataGridView->Rows[ 4 ], L"******************" );
}

int ratingColumn;
void UpdateStars( DataGridViewRow^ row, String^ stars )
{
   row->Cells[ ratingColumn ]->Value = stars;
   
   // Resize the column width to account for the new value.
   row->DataGridView->AutoResizeColumn( ratingColumn, DataGridViewAutoSizeColumnMode::DisplayedCells );
}
// Give cheescake excellent rating.
private void Button8_Click(object sender,
    System.EventArgs e)
{
    UpdateStars(dataGridView.Rows[4], "******************");
}

int ratingColumn = 3;

private void UpdateStars(DataGridViewRow row, string stars)
{

    row.Cells[ratingColumn].Value = stars;

    // Resize the column width to account for the new value.
    row.DataGridView.AutoResizeColumn(ratingColumn, 
        DataGridViewAutoSizeColumnMode.DisplayedCells);
}
' Give cheescake excellent rating.
Private Sub Button8_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button8.Click

    UpdateStars(dataGridView.Rows(4), "******************")
End Sub

Private ratingColumn As Integer = 3

Private Sub UpdateStars(ByVal row As DataGridViewRow, _
    ByVal stars As String)

    row.Cells(ratingColumn).Value = stars

    ' Resize the column width to account for the new value.
    row.DataGridView.AutoResizeColumn(ratingColumn, _
        DataGridViewAutoSizeColumnMode.DisplayedCells)

End Sub

설명

이 속성에 액세스할 때 행에 셀이 없으면 메서드를 호출하여 CreateCellsInstanceDataGridViewCellCollection 셀이 새로 만들어집니다.

적용 대상

추가 정보