Lab 1: Creating a Data-Bound Windows Form in Visual Studio .NET

Print QR Code ISO/IEC18004 in Visual Studio .NET Lab 1: Creating a Data-Bound Windows Form

Lab 1: Creating a Data-Bound Windows Form
Draw QR Code JIS X 0510 In .NET
Using Barcode printer for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
www.OnBarcode.com
Print Bar Code In .NET
Using Barcode generation for ASP.NET Control to generate, create barcode image in ASP.NET applications.
www.OnBarcode.com
In this lab you will create a Windows Form with controls bound to data.
QR Code Creation In Visual C#.NET
Using Barcode drawer for VS .NET Control to generate, create QR Code image in VS .NET applications.
www.OnBarcode.com
QR Code JIS X 0510 Creation In .NET Framework
Using Barcode maker for .NET Control to generate, create QR Code ISO/IEC18004 image in .NET applications.
www.OnBarcode.com
Exercise 1: Create a Data-Bound Form with the Data Sources Wizard
Encode QR-Code In Visual Basic .NET
Using Barcode encoder for .NET framework Control to generate, create QR Code ISO/IEC18004 image in Visual Studio .NET applications.
www.OnBarcode.com
Make UPC-A In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create UPC A image in ASP.NET applications.
www.OnBarcode.com
Let s now create a Windows application and demonstrate creating a data source and binding controls to data by dragging and dropping items from the Data Sources window. 1. Create a Windows application and name it DataSourcesWizardExample. 2. Start the Data Source Configuration Wizard by selecting Add New Data Source from the Data menu. 3. On the Choose a Data Source Type page, leave the default selection of Database and click Next. 4. On the Choose Your Data Connection page, select a connection to the Northwind sample database or create a new connection if needed. 5. Click Next, keeping the default values until you get to the Choose Your Database Objects page, and select the following from the Tables node:
Making Code 128 In .NET
Using Barcode creator for ASP.NET Control to generate, create ANSI/AIM Code 128 image in ASP.NET applications.
www.OnBarcode.com
Bar Code Maker In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create bar code image in ASP.NET applications.
www.OnBarcode.com
Customers Orders
Create Code 39 In .NET
Using Barcode generator for ASP.NET Control to generate, create Code 3/9 image in ASP.NET applications.
www.OnBarcode.com
Encode QR Code In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create QR image in ASP.NET applications.
www.OnBarcode.com
8
Barcode Creator In .NET Framework
Using Barcode creation for ASP.NET Control to generate, create bar code image in ASP.NET applications.
www.OnBarcode.com
Print Code 93 Full ASCII In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create Code 9/3 image in ASP.NET applications.
www.OnBarcode.com
Implementing Data-Bound Controls
EAN 13 Scanner In .NET Framework
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Paint UPC-A Supplement 5 In Visual C#.NET
Using Barcode encoder for VS .NET Control to generate, create UPC-A Supplement 2 image in Visual Studio .NET applications.
www.OnBarcode.com
Order Details
Generate Code-128 In None
Using Barcode generator for Online Control to generate, create Code 128B image in Online applications.
www.OnBarcode.com
Barcode Generation In .NET
Using Barcode creation for Reporting Service Control to generate, create barcode image in Reporting Service applications.
www.OnBarcode.com
6. Click Finish to add the dataset to your project. 7. On the Data menu, select Show Data Sources to display the Data Sources window. The Data Sources window should appear similar to Figure 8-1.
Make GS1-128 In Java
Using Barcode drawer for Java Control to generate, create EAN / UCC - 14 image in Java applications.
www.OnBarcode.com
Print Code39 In None
Using Barcode creator for Font Control to generate, create Code 3/9 image in Font applications.
www.OnBarcode.com
Figure 8-1 Data Sources window displaying the Customers, Orders, and Order Details tables from the NorthwindDataSet
Bar Code Decoder In Java
Using Barcode Control SDK for Eclipse BIRT Control to generate, create, read, scan barcode image in BIRT reports applications.
www.OnBarcode.com
Make Code128 In Java
Using Barcode encoder for BIRT Control to generate, create Code 128A image in BIRT applications.
www.OnBarcode.com
8. Drag the Customers node from the Data Sources window onto Form1. A DataGridView and BindingNavigator are added to the form, and several datarelated objects appear in the component tray, as shown in Figure 8-2.
Figure 8-2 Form1 and additional components after dragging Customers node from the Data Sources window
Lesson 1: Creating a Data-Bound Form with the Data Sources Wizard
9. Run the application. At this point, you have a working application with a DataGridView data-bound to the Customers table. If you switch to code view in the Integrated Development Environment (IDE), you can see that code has been added to fill the Customers table with data in the form load event, and code has been added to the save but
ton of the BindingNavigator to send updates back to the database.
The running application should display the Customers data as shown in Figure 8-3.
Figure 8-3
Form displaying data from the Customers table
10. Stop the application and open the form in Design view. 11. Expand the Customers node in the Data Sources window. 12. Drag the Orders node (nested within the Customers node) onto the form. Notice the OrdersBindingSource and OrdersTableAdapter added to the component tray. 13. Run the application. Click a row in the Customers table. Notice that the Orders DataGridView displays all orders for the selected customer, as shown in Figure 8-4.
8
Implementing Data-Bound Controls
Figure 8-4
Form displaying Orders data for the selected customer
Lesson Summary
Populate the Data Sources window by running the Data Source Configuration Wizard. Drag items from the Data Sources window to create data-bound controls on a form. Code to fill the table with data and to save changes back to the database is auto matically added to the form. In the Data Sources window, related records are displayed as nested nodes in the tree view.
Lesson Review
The following questions are intended to reinforce key information presented in this lesson. The questions are also available on the companion CD if you prefer to review them in electronic form.
NOTE
Answers
Answers to these questions and explanations of why each choice is right or wrong are located in the Answers section at the end of the book.
Lesson 1: Creating a Data-Bound Form with the Data Sources Wizard
1. How do you add items to the Data Sources window (Choose all that apply.) A. Select Add New Data Source from the Data Sources window. B. Drag a DataSet from the Toolbox onto a form. C. Select Add New Data Source from the Data menu. D. Run the Data Source Configuration Wizard. 2. How do you create data-bound controls on a Windows Form A. Drag items from Server Explorer onto the Dataset Designer. B. Drag items from the Data Sources window onto a form. C. Drag items from the Toolbox onto a form. D. Set data related Form properties in the Properties window. 3. How do you bind controls to display data from related tables on a Windows Form A. By selecting the main node of the related table in the Data Sources window and dragging it onto a form B. By selecting the child node in the Data Sources window and dragging it onto a form C. By dragging a Relation object onto the Dataset Designer D. By binding to the child DataTable in the DataSet
Copyright © OnBarcode.com . All rights reserved.