DataGridViewColumn.DefaultCellStyle DataGridViewColumn.DefaultCellStyle DataGridViewColumn.DefaultCellStyle DataGridViewColumn.DefaultCellStyle Property

Definition

Ruft das Standardzellenformat der Spalte ab oder legt dieses fest.Gets or sets the column's default cell style.

public:
 virtual property System::Windows::Forms::DataGridViewCellStyle ^ DefaultCellStyle { System::Windows::Forms::DataGridViewCellStyle ^ get(); void set(System::Windows::Forms::DataGridViewCellStyle ^ value); };
[System.ComponentModel.Browsable(true)]
public override System.Windows.Forms.DataGridViewCellStyle DefaultCellStyle { get; set; }
member this.DefaultCellStyle : System.Windows.Forms.DataGridViewCellStyle with get, set
Public Overrides Property DefaultCellStyle As DataGridViewCellStyle

Eigenschaftswert

Ein DataGridViewCellStyle, der den Standardstil der Zellen in der Spalte darstellt.A DataGridViewCellStyle that represents the default style of the cells in the column.

Beispiele

Im folgenden Codebeispiel wird die DefaultCellStyle -Eigenschaft verwendet, um die Inhalts Ausrichtung verschiedener Spalten festzulegen.The following code example uses the DefaultCellStyle property to set the content alignment of various columns.

private void ChangeColumnAlignment()
{
    songsDataGridView.Columns["Title"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
    songsDataGridView.Columns["Title"].Name = DataGridViewContentAlignment.BottomCenter.ToString();

    songsDataGridView.Columns["Artist"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft;
    songsDataGridView.Columns["Artist"].Name = DataGridViewContentAlignment.BottomLeft.ToString();

    songsDataGridView.Columns["Album"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
    songsDataGridView.Columns["Album"].Name = DataGridViewContentAlignment.BottomRight.ToString();

    songsDataGridView.Columns["Release Date"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
    songsDataGridView.Columns["Release Date"].Name = DataGridViewContentAlignment.MiddleCenter.ToString();

    songsDataGridView.Columns["Track"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
    songsDataGridView.Columns["Track"].Name = DataGridViewContentAlignment.MiddleLeft.ToString();
}
Private Sub ChangeColumnAlignment()
    songsDataGridView.Columns("Title").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
    songsDataGridView.Columns("Title").Name = DataGridViewContentAlignment.BottomCenter.ToString()

    songsDataGridView.Columns("Artist").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft
    songsDataGridView.Columns("Artist").Name = DataGridViewContentAlignment.BottomLeft.ToString()

    songsDataGridView.Columns("Album").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight
    songsDataGridView.Columns("Album").Name = DataGridViewContentAlignment.BottomRight.ToString()

    songsDataGridView.Columns("Release Date").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
    songsDataGridView.Columns("Release Date").Name = DataGridViewContentAlignment.MiddleCenter.ToString()

    songsDataGridView.Columns("Track").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
    songsDataGridView.Columns("Track").Name = DataGridViewContentAlignment.MiddleLeft.ToString()
End Sub

Hinweise

Das DataGridView -Steuerelement zeigt seine Zellen mithilfe der Stile an, InheritedStyle die von der Cell-Eigenschaft angegeben werden, die Stile DataGridViewCellStylevon anderen Eigenschaften des Typs erbt.The DataGridView control displays its cells using the styles indicated by the cell InheritedStyle property, which inherits styles from other properties of type DataGridViewCellStyle. Bei Zellen in dieser Spalte überschreiben die durch die DefaultCellStyle -Eigenschaft angegebenen Stile die durch die DataGridView.DefaultCellStyle -Eigenschaft angegebenen Stile, werden jedoch von DataGridView.RowsDefaultCellStyleden durch die-, DataGridView.AlternatingRowsDefaultCellStyle DataGridViewRow.DefaultCellStyle-,-und-Eigenschaft angegebenen Stilen überschrieben. DataGridViewCell.Style Eigenschaften.For cells in this column, the styles specified through the DefaultCellStyle property override the styles specified through the DataGridView.DefaultCellStyle property, but are overridden by the styles specified through the DataGridView.RowsDefaultCellStyle, DataGridView.AlternatingRowsDefaultCellStyle, DataGridViewRow.DefaultCellStyle, and DataGridViewCell.Style properties.

Weitere Informationen finden Sie unter Zellen Stile im Windows Forms DataGridView-SteuerElement.For more information, see Cell Styles in the Windows Forms DataGridView Control.

Gilt für:

Siehe auch