DataGridViewContentAlignment DataGridViewContentAlignment DataGridViewContentAlignment DataGridViewContentAlignment Enum

定义

定义常数,该常数指示 DataGridView 单元格中内容的对齐方式。Defines constants that indicate the alignment of content within a DataGridView cell.

public enum class DataGridViewContentAlignment
public enum DataGridViewContentAlignment
type DataGridViewContentAlignment = 
Public Enum DataGridViewContentAlignment
继承
DataGridViewContentAlignmentDataGridViewContentAlignmentDataGridViewContentAlignmentDataGridViewContentAlignment

字段

BottomCenter BottomCenter BottomCenter BottomCenter 512

内容与单元格的底部垂直对齐,与单元格的中间水平对齐。The content is aligned vertically at the bottom and horizontally at the center of a cell.

BottomLeft BottomLeft BottomLeft BottomLeft 256

内容与单元格的底部垂直对齐,与单元格的左侧水平对齐。The content is aligned vertically at the bottom and horizontally at the left of a cell.

BottomRight BottomRight BottomRight BottomRight 1024

内容与单元格的底部垂直对齐,与单元格的右侧水平对齐。The content is aligned vertically at the bottom and horizontally at the right of a cell.

MiddleCenter MiddleCenter MiddleCenter MiddleCenter 32

内容与单元格的垂直和水平中心对齐。The content is aligned at the vertical and horizontal center of a cell.

MiddleLeft MiddleLeft MiddleLeft MiddleLeft 16

内容与单元格的中间垂直对齐,与单元格的左侧水平对齐。The content is aligned vertically at the middle and horizontally at the left of a cell.

MiddleRight MiddleRight MiddleRight MiddleRight 64

内容与单元格的中间垂直对齐,与单元格的右侧水平对齐。The content is aligned vertically at the middle and horizontally at the right of a cell.

NotSet NotSet NotSet NotSet 0

未设定对齐方式。The alignment is not set.

TopCenter TopCenter TopCenter TopCenter 2

内容与单元格的顶部垂直对齐,与单元格的中间水平对齐。The content is aligned vertically at the top and horizontally at the center of a cell.

TopLeft TopLeft TopLeft TopLeft 1

内容与单元格的顶部垂直对齐,与单元格的左侧水平对齐。The content is aligned vertically at the top and horizontally at the left of a cell.

TopRight TopRight TopRight TopRight 4

内容与单元格的顶部垂直对齐,与单元格的右侧水平对齐。The content is aligned vertically at the top and horizontally at the right of a cell.

示例

下面的代码示例演示如何使用此类型。The following code example illustrates the use of this type. 有关详细信息,请参阅如何:设置 Windows 窗体 DataGridView 控件中的数据格式For more information, see How to: Format Data in the Windows Forms DataGridView Control.

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

注解

此枚举由DataGridViewCellStyle.Alignment属性使用。This enumeration is used by the DataGridViewCellStyle.Alignment property.

适用于

另请参阅