DataGridViewCheckBoxCell.FlatStyle Property

Definition

Gets or sets the flat style appearance of the check box user interface (UI).

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

Property Value

One of the FlatStyle values. The default is Standard.

Exceptions

The specified value when setting this property is not a valid FlatStyle value.

Examples

The following code example demonstrates the use of the DataGridViewCheckBoxColumn.FlatStyle property, which is similar to this property. This example is part of a larger example available in the DataGridViewComboBoxColumn class overview topic.

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

Remarks

The Popup flat style is not supported by this cell type.

Setting the FlatStyle property of the owning column also sets the FlatStyle property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value.

Applies to

See also