DataGridViewCellStyle.Alignment 屬性

定義

取得或設定值,表示 DataGridView 儲存格內儲存格內容的位置。Gets or sets a value indicating the position of the cell content within a DataGridView cell.

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

屬性值

其中一個 DataGridViewContentAlignment 值。One of the DataGridViewContentAlignment values. 預設為 NotSetThe default is NotSet.

例外狀況

屬性值不是有效的 DataGridViewContentAlignment 值。The property value is not a valid DataGridViewContentAlignment value.

範例

下列程式碼範例說明如何使用這個屬性。The following code example illustrates the use of this property.

this.dataGridView1.Columns["CustomerName"].DefaultCellStyle
    .Alignment = DataGridViewContentAlignment.MiddleRight;
Me.dataGridView1.Columns("CustomerName").DefaultCellStyle _
    .Alignment = DataGridViewContentAlignment.MiddleRight

適用於

另請參閱