DataGridView 控件(Windows 窗体)DataGridView Control (Windows Forms)

DataGridView 控件提供一种以表格格式显示数据的功能强大且灵活的方法。The DataGridView control provides a powerful and flexible way to display data in a tabular format. 可以使用 DataGridView 控件来显示少量数据的只读视图,或者可以缩放该控件以显示大型数据集的可编辑视图。You can use the DataGridView control to show read-only views of a small amount of data, or you can scale it to show editable views of very large sets of data.

可以使用多种方法扩展 DataGridView 控件,以便将自定义行为置入你的应用程序中。You can extend the DataGridView control in a number of ways to build custom behaviors into your applications. 例如,可以以编程方式指定自己的排序算法,并且可以创建自己的单元格类型。For example, you can programmatically specify your own sorting algorithms, and you can create your own types of cells. 可以通过在多个属性之间进行选择来轻松地自定义 DataGridView 控件的外观。You can easily customize the appearance of the DataGridView control by choosing among several properties. 许多数据存储类型均可用作数据源,或者,DataGridView 控件可以在不绑定任何数据源的情况下进行操作。Many types of data stores can be used as a data source, or the DataGridView control can operate with no data source bound to it.

本节中的主题介绍可用于将 DataGridView 功能构建到应用程序中的概念和技术。The topics in this section describe the concepts and techniques that you can use to build DataGridView features into your applications.

本节内容In This Section

DataGridView 控件概述DataGridView Control Overview
提供一些主题,介绍 Windows 窗体 DataGridView 控件的体系结构和核心概念。Provides topics that describe the architecture and core concepts of the Windows Forms DataGridView control.

Windows 窗体 DataGridView 控件中的默认功能Default Functionality in the Windows Forms DataGridView Control
描述 Windows 窗体 DataGridView 控件在绑定到数据源时的默认外观和行为。Describes the default appearance and behavior of the Windows Forms DataGridView control when it is bound to a data source.

Windows 窗体 DataGridView 控件中的列类型Column Types in the Windows Forms DataGridView Control
描述 Windows 窗体 DataGridView 控件中用于显示数据和允许用户修改或添加数据的列类型。Describes the column types in the Windows Forms DataGridView control used to display data and allow users to modify or add data.

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.

Windows 窗体 DataGridView 控件中的基本格式和样式设置Basic Formatting and Styling in the Windows Forms DataGridView Control
提供一些主题,描述如何修改该控件的基本外观和单元数据的显示格式。Provides topics that describe how to modify the basic appearance of the control and the display formatting of cell data.

在 Windows 窗体 DataGridView 控件中显示数据Displaying Data in the Windows Forms DataGridView Control
提供一些主题,描述如何手动或从外部数据源向控件填充数据。Provides topics that describe how to populate the control with data either manually, or from an external data source.

调整 Windows 窗体 DataGridView 控件中列和行的大小Resizing Columns and Rows in the Windows Forms DataGridView Control
提供一些主题,描述可如何自动调整行和列的大小,以便适应单元格内容,或适应该控件的可用宽度。Provides topics that describe how the size of rows and columns can be adjusted automatically to fit cell content or to fit the available width of the control.

在 Windows 窗体 DataGridView 控件中进行数据排序Sorting Data in the Windows Forms DataGridView Control
提供介绍控件中的排序功能的主题。Provides topics that describe the sorting features in the control.

Windows 窗体 DataGridView 控件中的数据输入Data Entry in the Windows Forms DataGridView Control
提供一些主题,介绍如何改变用户添加和修改控件中数据的方式。Provides topics that describe how to change the way users add and modify data in the control.

将选择模式和剪贴板与 Windows 窗体 DataGridView 控件结合使用Selection and Clipboard Use with the Windows Forms DataGridView Control
提供一些主题,介绍控件中的单元格、行和列选择功能。Provides topics that describe the cell, row, and column selection features in the control.

使用 Windows 窗体 DataGridView 控件中的单元格、行和列编程Programming with Cells, Rows, and Columns in the Windows Forms DataGridView Control
提供一些主题,介绍如何使用单元格、行和列对象进行编程。Provides topics that describe how to program with cell, row, and column objects.

自定义 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 控件中的性能调整Performance Tuning in the Windows Forms DataGridView Control
提供一些主题,介绍如何在使用大量数据时,有效地使用控件以避免性能问题。Provides topics that describe how to use the control efficiently to avoid performance problems when working with large amounts of data.

Windows 窗体 DataGridView 控件中的默认键盘和鼠标处理Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control
介绍用户可如何通过键盘和鼠标与 DataGridView 控件进行交互。Describes how users can interact with the DataGridView control through a keyboard and a mouse.

Windows 窗体 DataGridView 控件和 DataGrid 控件之间的区别Differences Between the Windows Forms DataGridView and DataGrid Controls
描述 DataGridView 控件如何改进和替换 DataGrid 控件。Describes how the DataGridView control improves upon and replaces the DataGrid control.

另请参阅设计器中使用 Windows 窗体 DataGridView 控件Also see Using the Designer with the Windows Forms DataGridView Control.

参考Reference

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

BindingSource
提供关于 BindingSource 组件的参考文档。Provides reference documentation for the BindingSource component. DataGridView 控件和 BindingSource 组件设计为需紧密协作。The DataGridView control and the BindingSource component are designed to work closely together.

请参阅See also