DataGridViewContentAlignment 枚举
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义常数,该常数指示 DataGridView 单元格中内容的对齐方式。
public enum class DataGridViewContentAlignment
C#
public enum DataGridViewContentAlignment
type DataGridViewContentAlignment =
Public Enum 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;
Me.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 |