If you've worked with typed Data Sets in VS 2003, you'll notice that the schema for ADO 2.0 Data Sets is much more verbose than the ADO 1.x version, which has only 30 lines that define the Customers Data Set. NET 2.0 prefixes the design-time schema with 258 lines of information, which provide a full definition of the Data Set and its connection string, commands and their parameters, and column mapping data. Write Xml Schema methods to persist Data Sets to local files shows that the Customers Data Set schema, which differs greatly from the design-time version, is 9.31KB and the XML data document is 37.3KB. Figure 1-12 The Customers Data Grid View is bound to the Northwind Customers table, and editing is enabled by default. The Data Sources window makes it easy to change a Data Grid View to a details form.The part of the schema that defines the elements for the table fields grows from 30 to 94 lines because element definitions now contain max Length attribute values and use restriction Base attributes to specify XSD data types. The section "Create a Complete Data Entry Form in One Step," later in this chapter, includes code to save the schema for the Northwind Customers Data Set. Changes you make to the Data Grid View don't propagate to the table until you click the Save Data button. Delete the Data Grid View control, display the Data Sources window, open the dropdown list for the Data Table, and select Details, as shown in Figure 1-13.Figure 1-11 "Surfacing" is a common term for adding data and other components to the tray. Customers) End Sub Private Sub data Navigator Save Item_Click(By Val sender As System. To add a related Orders Data Grid View control to a copy of the Generated Detail project, do the following: 1. Auto Size Rows Mode property value to Displayed Cells. The Orders Data Grid View control's Data Source property value is the Orders Binding Source.
This book uses the term data component to refer to named design-time data objects that reside in the form design tray.Expand the Customers node to display the Customers table's columns, as shown in Figure 1-8 The new Sql Connection object you created in preceding Steps 3 through 5 appears under Server Explorer's Data Connections node as Server Name. You can rename the node in Server Explorer to a simpler name, such as localhost.Northwind; doing this doesn't affect dependent objects in your project.You can't open the saved schema in the project's Schema Designer. To make editing easier, you can automate increasing the column widths to match the content by setting the Data Grid View's Auto Size Columns Mode property value to All Cells or Displayed Cells, which adds a horizontal scrollbar to the control. Figure 1-13 Drag the Data Table icon to the form to automatically add a column of labels with associated data-bound Controls -- text boxes for this example -- to the form.Add a Data Grid View and Binding Navigator Controls Opening Form1 and the Data Sources window changes the appearance of the Data Source nodes. Persist and Reopen the Data Set The project's frm Data Grid View_Load event handler includes the following code to save the Northwind Data Set's XML data document -- with and without an embedded schema -- and the schema only. Figure 1-14, which is a modified version of the Generated Data Grid View project, shows the labels and text boxes rearranged to reduce form height.