Share via


DataGridViewCheckBoxColumn.FlatStyle Propiedad

Definición

Obtiene o establece la apariencia de estilo plano de las celdas de casilla.

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

Valor de propiedad

FlatStyle

Un valor de FlatStyle que indica el aspecto de las celdas de la columna. De manera predeterminada, es Standard.

Excepciones

El valor de la propiedad CellTemplate es null.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar para DataGridViewCheckBoxColumn marcar qué empleados están fuera de la oficina. Este ejemplo forma parte de un ejemplo más grande disponible en el tema de información general de la DataGridViewComboBoxColumn clase.

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

Comentarios

Para mostrar las celdas de casilla mediante estilos visuales, establezca esta propiedad System en y llame al Application.EnableVisualStyles método antes Application.Runde .

Obtener o establecer esta propiedad obtiene o establece la FlatStyle propiedad del objeto de celda devuelto por la CellTemplate propiedad . Al establecer esta propiedad también se establece la FlatStyle propiedad de todas las celdas de la columna y se actualiza la presentación de la columna. Para invalidar el valor especificado para celdas individuales, establezca los valores de celda después de establecer el valor de columna.

Se aplica a

Consulte también