DataGridViewCellStyle.Alignment 属性

定义

获取或设置一个值,该值指示 DataGridView 单元格内的单元格内容的位置。

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

DataGridViewContentAlignment 值之一。 默认值为 NotSet

例外

示例

下面的代码示例演示了此属性的使用。

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

适用于

另请参阅