DataGridViewCheckBoxColumn.FlatStyle Eigenschap

Definitie

Hiermee haalt u het uiterlijk van de platte stijl van de selectievakjecellen op of stelt u deze in.

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

Waarde van eigenschap

Een FlatStyle waarde die het uiterlijk van cellen in de kolom aangeeft. De standaardwaarde is Standard.

Uitzonderingen

De waarde van de CellTemplate eigenschap is null.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u een DataGridViewCheckBoxColumn code gebruikt om aan te geven welke werknemers niet op kantoor zijn. Dit voorbeeld maakt deel uit van een groter voorbeeld dat beschikbaar is in het overzichtsonderwerp van de DataGridViewComboBoxColumn klas.

private:
    void AddOutOfOfficeColumn()
    {
        DataGridViewCheckBoxColumn^ column = gcnew DataGridViewCheckBoxColumn();
        {
            column->HeaderText = ColumnName::OutOfOffice.ToString();
            column->Name = ColumnName::OutOfOffice.ToString();
            column->AutoSizeMode = 
                DataGridViewAutoSizeColumnMode::DisplayedCells;
            column->FlatStyle = FlatStyle::Standard;
            column->ThreeState = true;
            column->CellTemplate = gcnew DataGridViewCheckBoxCell();
            column->CellTemplate->Style->BackColor = Color::Beige;
        }

        DataGridView1->Columns->Insert(0, column);
    }
private void AddOutOfOfficeColumn()
{
    DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
    {
        column.HeaderText = ColumnName.OutOfOffice.ToString();
        column.Name = ColumnName.OutOfOffice.ToString();
        column.AutoSizeMode = 
            DataGridViewAutoSizeColumnMode.DisplayedCells;
        column.FlatStyle = FlatStyle.Standard;
        column.ThreeState = true;
        column.CellTemplate = new DataGridViewCheckBoxCell();
        column.CellTemplate.Style.BackColor = Color.Beige;
    }

    DataGridView1.Columns.Insert(0, column);
}
Private Sub AddOutOfOfficeColumn()
    Dim column As New DataGridViewCheckBoxColumn()
    With column
        .HeaderText = ColumnName.OutOfOffice.ToString()
        .Name = ColumnName.OutOfOffice.ToString()
        .AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
        .FlatStyle = FlatStyle.Standard
        .CellTemplate = New DataGridViewCheckBoxCell()
        .CellTemplate.Style.BackColor = Color.Beige
    End With

    DataGridView1.Columns.Insert(0, column)
End Sub

Opmerkingen

Als u de selectievakjecellen wilt weergeven met behulp van visuele stijlen, stelt u deze eigenschap in op System en roept u de Application.EnableVisualStyles methode daarvoor Application.Runaan.

Als u deze eigenschap ophaalt of instelt, wordt de FlatStyle eigenschap van het celobject opgehaald of ingesteld dat door de CellTemplate eigenschap wordt geretourneerd. Als u deze eigenschap instelt, wordt ook de FlatStyle eigenschap van elke cel in de kolom ingesteld en wordt de kolomweergave vernieuwd. Als u de opgegeven waarde voor afzonderlijke cellen wilt overschrijven, stelt u de celwaarden in nadat u de kolomwaarde hebt ingesteld.

Van toepassing op

Zie ook