Windows Form DataGridView 控制項中的基本格式化和樣式設定

控制項 DataGridView 可讓您輕鬆地定義儲存格的基本外觀,以及儲存格值的顯示格式設定。 您可以藉由設定透過各種 DataGridView 控制項屬性存取的物件屬性 DataGridViewCellStyle ,定義個別儲存格的外觀和格式化樣式、特定資料行和資料列中的儲存格,或針對控制項中的所有儲存格定義。 此外,您可以處理 CellFormatting 事件,根據儲存格值等因素動態修改這些樣式。

本節內容

操作說明:變更 Windows Forms DataGridView 控制項中的框線和格線樣式
描述如何設定 DataGridView 屬性,以定義控制項框線的外觀和儲存格之間的界限線。

Windows Forms DataGridView 控制項中的儲存格樣式
描述 類別 DataGridViewCellStyle ,以及該型別的屬性如何互動,以定義控制項中儲存格的顯示方式。

操作說明:設定 Windows Forms DataGridView 控制項的預設儲存格樣式
描述如何使用 DataGridViewCellStyle 屬性來定義特定資料列和資料行和整個控制項中儲存格的預設面板。

操作說明:格式化 Windows Forms DataGridView 控制項中的資料
描述如何使用屬性來格式化儲存格顯示值 DataGridViewCellStyle

操作說明:設定 Windows Forms DataGridView 控制項的字型和色彩樣式
描述如何使用 DefaultCellStyle 屬性來設定控制項中所有儲存格的基本顯示特性。

操作說明:設定 Windows Forms DataGridView 控制項的替代資料列樣式
描述如何使用不同方式顯示的替代資料列,在 控制項中建立類似總帳的效果。

操作說明:在 Windows Forms DataGridView 控制項中使用資料列範本自訂資料列
描述如何使用 RowTemplate 屬性來設定將用於 控制項中所有資料列的資料列屬性。

參考

DataGridView
提供 DataGridView 控制項的參考文件。

DataGridViewCellStyle
提供 類別的 DataGridViewCellStyle 參考檔。

CellFormatting
提供事件的參考檔 CellFormatting

RowTemplate
提供 屬性的 RowTemplate 參考檔。

自訂 Windows Forms DataGridView 控制項
提供主題描述自訂繪製 DataGridView 儲存格和資料列,並建立衍生儲存格、資料行和資料列類型。

Windows Forms DataGridView 控制項中的基本資料行、資料列和儲存格功能
提供描述常用儲存格、資料列和資料行屬性的主題。

另請參閱