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 Forms 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

另請參閱