DataGridViewContentAlignment 枚举

定义

定义常数,该常数指示 DataGridView 单元格中内容的对齐方式。

C#
public enum DataGridViewContentAlignment
继承
DataGridViewContentAlignment

字段

BottomCenter 512

内容与单元格的底部垂直对齐,与单元格的中间水平对齐。

BottomLeft 256

内容与单元格的底部垂直对齐,与单元格的左侧水平对齐。

BottomRight 1024

内容与单元格的底部垂直对齐,与单元格的右侧水平对齐。

MiddleCenter 32

内容与单元格的垂直和水平中心对齐。

MiddleLeft 16

内容与单元格的中间垂直对齐,与单元格的左侧水平对齐。

MiddleRight 64

内容与单元格的中间垂直对齐,与单元格的右侧水平对齐。

NotSet 0

未设定对齐方式。

TopCenter 2

内容与单元格的顶部垂直对齐,与单元格的中间水平对齐。

TopLeft 1

内容与单元格的顶部垂直对齐,与单元格的左侧水平对齐。

TopRight 4

内容与单元格的顶部垂直对齐,与单元格的右侧水平对齐。

示例

下面的代码示例演示了此类型的用法。 有关详细信息,请参阅如何:设置 Windows 窗体 DataGridView 控件中的数据格式

C#
this.dataGridView1.Columns["CustomerName"].DefaultCellStyle
    .Alignment = DataGridViewContentAlignment.MiddleRight;

注解

该属性使用此 DataGridViewCellStyle.Alignment 枚举。

适用于

产品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另请参阅