![]() The relationships between a set of tables are displayed using a parent/child structure of navigation. The user can also add rows and edit cells. When the DataGrid control is displaying a table and the AllowSorting property is set to true, data can be resorted by clicking the column headers. The DataGrid control can be used to display either a single table or the hierarchical relationships between a set of tables. For more information about possible data sources, see Binding the Windows Forms DataGrid Control to a Data Source. There are other possible data sources, but the above are the most typical. Valid data sources for the DataGrid include: For information about binding a DataGrid control to an ADO.NET data source at either design time or run time, see Binding the Windows Forms DataGrid Control to a Data Source. If a parent-child relationship is defined between tables, the user can navigate between the related tables to select the table to be displayed in the DataGrid control. Only one table can be shown in the DataGrid at a time. If the data grid and its table styles and column styles have the ReadOnly property set to false, the data in the dataset can be updated through the DataGrid control. If the data in the bound dataset is updated through any mechanism, the DataGrid control reflects the changes. Most data-specific actions are not performed through the DataGrid, but instead through the data source. This binding points the DataGrid to an instantiated data-source object (such as a DataSet or DataTable), with the DataGrid control showing the results of actions that are performed on the data. Binding Data to the Control In order for the DataGrid control to work, it should be bound to a data source using the DataSource and DataMember properties at design time or the SetDataBinding method at run time. Following the generation of the DataGrid control, columns can be added, deleted, rearranged, and formatted as needed. For details, see Data Binding and Windows Forms. When the grid is bound to a DataSet object, the columns and rows are automatically created, formatted, and filled. For details, see DataGrid Control Changes in Visual Basic. Visual Basic Note If you are familiar with the DataGrid control in Visual Basic 6.0, you will find some significant differences in the Windows Forms DataGrid control. Therefore, multiple controls bound to the same data source will stay in sync. The display and manipulation of data are separate functions: The control handles the user interface, while data updates are handled by the Windows Forms data-binding architecture and by. ![]() The DataGrid can provide a user interface for a dataset, navigation between related tables, and rich formatting and editing capabilities. In this fashion, the grid displays the hierarchical relationships between tables.Ī DataGrid bound to data with multiple tables Clicking a node displays the child table, and clicking the Back button displays the original parent table. An expander allows navigation from a parent table to a child table. If the DataGrid is bound to data with multiple related tables, and if navigation is enabled on the grid, the grid will display expanders in each row. For details about binding data to other controls, see Data Binding and Windows Forms. In that case, the data appears in simple rows and columns, as in a spreadsheet. The simplest case is when the grid is bound to a data source with a single table containing no relationships. ![]() The Windows Forms DataGrid control displays data in a series of rows and columns.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |