更新:2007 年 11 月
DataGridView 控件使您可以轻松定义单元格的基本外观和单元格值的显示格式。可以通过设置 DataGridViewCellStyle 对象(可通过各种 DataGridView 控件属性访问它)的属性,来为单个单元格、为特定列和行中的单元格或者为控件中的所有单元格定义外观和格式样式。另外,通过处理 CellFormatting 事件,可以基于诸如单元格值这样的因素来动态地修改这些样式。
本节内容
- 如何:更改 Windows 窗体 DataGridView 控件中的边框和网格线的样式 
 描述如何设置用于定义控件边框的外观和单元格之间的边界线的 DataGridView 属性。
- Windows 窗体 DataGridView 控件中的单元格样式 
 描述 DataGridViewCellStyle 类以及该类型的属性如何交互,以定义单元格在控件中的显示方式。
- 如何:设置 Windows 窗体 DataGridView 控件的默认单元格样式 
 描述如何使用 DataGridViewCellStyle 属性来定义在特定的行和列中以及在整个控件中的单元格的默认外观。
- 如何:设置 Windows 窗体 DataGridView 控件中的数据格式 
 描述如何使用 DataGridViewCellStyle 属性来格式化单元格的显示值。
- 如何:设置 Windows 窗体 DataGridView 控件中的字体和颜色样式 
 描述如何使用 DefaultCellStyle 属性来为控件中的所有单元格设置基本显示特征。
- 如何:为 Windows 窗体 DataGridView 控件设置交替行样式 
 描述如何使用以不同方式显示的交替行在控件中创建类似帐目型的效果。
- 如何:使用行模板自定义 Windows 窗体 DataGridView 控件中的行 
 描述如何使用 RowTemplate 属性来设置将用于控件中所有行的行属性。
参考
- DataGridView 
 提供 DataGridView 控件的参考文档。
- DataGridViewCellStyle 
 提供 DataGridViewCellStyle 类的参考文档。
- CellFormatting 
 提供 CellFormatting 事件的参考文档。
- RowTemplate 
 提供 RowTemplate 属性的参考文档。
相关章节
- 自定义 Windows 窗体 DataGridView 控件 
 提供一些主题,描述了如何自定义绘制 DataGridView 单元格和行,以及如何创建派生单元格、列和行类型。
- Windows 窗体 DataGridView 控件中的基本列、行和单元格功能 
 提供描述常用的单元格、行和列属性的主题。