Windows 窗体 DataGridView 控件中的基本格式设置和样式设置Basic Formatting and Styling in the Windows Forms DataGridView Control

DataGridView控件,可以轻松定义单元格的基本外观和单元格的值的显示格式。The DataGridView control makes it easy to define the basic appearance of cells and the display formatting of cell values. 您可以定义外观和设置的属性的各个单元格、 行和特定列中的单元格或控件中的所有单元格格式设置样式DataGridViewCellStyle访问通过各种对象DataGridView控件属性。You can define appearance and formatting styles for individual cells, for cells in specific columns and rows, or for all cells in the control by setting the properties of the DataGridViewCellStyle objects accessed through various DataGridView control properties. 此外,你可以修改基于动态因素,例如单元格的值通过处理这些样式CellFormatting事件。Additionally, you can modify these styles dynamically based on factors such as the cell value by handling the CellFormatting event.

本节内容In This Section

如何:更改边框和网格线在 Windows 窗体 DataGridView 控件中的样式How to: Change the Border and Gridline Styles in the Windows Forms DataGridView Control
介绍如何设置DataGridView属性用于定义控件边框和单元格之间的边界行的外观。Describes how to set DataGridView properties that define the appearance of the control border and the boundary lines between cells.

Windows 窗体 DataGridView 控件中的单元格样式Cell Styles in the Windows Forms DataGridView Control
介绍DataGridViewCellStyle类和该类型的属性是如何交互以定义单元格控件中的显示方式。Describes the DataGridViewCellStyle class and how properties of that type interact to define how cells are displayed in the control.

如何:设置 Windows 窗体 DataGridView 控件的默认单元格样式How to: Set Default Cell Styles for the Windows Forms DataGridView Control
介绍如何使用DataGridViewCellStyle属性以定义单元格的默认外观和整个控件中特定行和列。Describes how to use DataGridViewCellStyle properties to define the default appearance of cells in specific rows and columns and in the entire control.

如何:Windows 中的数据格式窗体 DataGridView 控件How to: Format Data in the Windows Forms DataGridView Control
介绍了如何设置使用的单元格显示值DataGridViewCellStyle属性。Describes how to format cell display values using DataGridViewCellStyle properties.

如何:在 Windows 窗体 DataGridView 控件中设置字体和颜色样式How to: Set Font and Color Styles in the Windows Forms DataGridView Control
介绍如何使用DefaultCellStyle要设置基本属性在控件中显示的所有单元格的特征。Describes how to use the DefaultCellStyle property to set basic display characteristics for all cells in the control.

如何:设置 Windows 窗体 DataGridView 控件的交替行样式How to: Set Alternating Row Styles for the Windows Forms DataGridView Control
介绍如何使用以不同方式显示的交替行在控件中创建一个类似分类帐的效果。Describes how to create a ledger-like effect in the control using alternating rows that are displayed differently.

如何:使用行模板自定义 Windows 窗体 DataGridView 控件中的行How to: Use the Row Template to Customize Rows in the Windows Forms DataGridView Control
介绍如何使用RowTemplate属性来设置将用于在控件中的所有行的行属性。Describes how to use the RowTemplate property to set row properties that will be used for all rows in the control.

参考Reference

DataGridView
提供关于 DataGridView 控件的参考文档。Provides reference documentation for the DataGridView control.

DataGridViewCellStyle
为提供参考文档DataGridViewCellStyle类。Provides reference documentation for the DataGridViewCellStyle class.

CellFormatting
为提供参考文档CellFormatting事件。Provides reference documentation for the CellFormatting event.

RowTemplate
为提供参考文档RowTemplate属性。Provides reference documentation for the RowTemplate property.

自定义 Windows 窗体 DataGridView 控件Customizing the Windows Forms DataGridView Control
提供一些主题,介绍自定义绘制 DataGridView 单元格和行,以及创建派生的单元、列和行类型。Provides topics that describe custom painting DataGridView cells and rows, and creating derived cell, column, and row types.

Windows 窗体 DataGridView 控件中的列、行和单元格基本功能Basic Column, Row, and Cell Features in the Windows Forms DataGridView Control
提供一些主题,介绍通常使用单元格、 行和列属性。Provides topics that describe commonly used cell, row, and column properties.

请参阅See also