If a parent-child relationship is defined between tables, the user can move 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. The DataGrid control shows the results of actions that are performed on the data. This binding points the DataGrid to an instantiated data-source object, such as a DataSet or DataTable). Binding Data to the Controlįor 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, you can add, delete, rearrange, and format columns and rows depending on your needs. For more information, see Data Binding and Windows Forms. When the grid is bound to a DataSet, the columns and rows are automatically created, formatted, and filled. 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, whereas 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. The following screenshot shows a DataGrid bound to data with multiple tables: In this manner, the grid displays the hierarchical relationships between tables. Clicking a node displays the child table, and clicking a back button displays the original parent table. With an expander, the user can move 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 more information 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 that contains no relationships. The Windows Forms DataGrid control displays data in a series of rows and columns. For more information, see Differences Between the Windows Forms DataGridView and DataGrid Controls. The DataGridView control replaces and adds functionality to the DataGrid control however, the DataGrid control is retained for both backward compatibility and future use, if you choose.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |