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

适用于

另请参阅