DataGridViewRow.Cells Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u de verzameling cellen op die de rij vullen.
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
Waarde van eigenschap
Een DataGridViewCellCollection met alle cellen in de rij.
- Kenmerken
Voorbeelden
In het volgende codevoorbeeld wordt de Cells eigenschap gebruikt om de waarde van een cel in de rij in te stellen. Dit codevoorbeeld maakt deel uit van een groter codevoorbeeld in Hoe u: Rijen bewerken in het Windows Forms DataGridView-besturingselement.
// 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
Opmerkingen
Als de rij geen cellen bevat wanneer deze eigenschap wordt geopend, wordt er een nieuwe lege DataGridViewCellCollection waarde gemaakt door een aanroep naar de CreateCellsInstance methode.