Data Binding
Database-centric applications are fully supported in WinForms. To get started, you can use Server Explorer to add connections to whatever databases you'd like. For example, Figure 1.18 shows Server Explorer and the tables in a database
Figure 1.18. A Database Connection in Server Explorer
Dragging a table from Server Explorer onto a Designer surface creates two
Associating a source of data, such as a data set, with one or more controls is known as data binding . Binding a control to a data source provides for bidirectional communication between the control and the data source so that when the data is modified in one place, it's propagated to the other. Several data bound controls are provided with WinForms, including ListBox and ComboBox, but of all of them, the DataGrid control is the most flexible. Figure 1.19 shows a form with a data grid bound to the data set that's already been created. Figure 1.19. A DataGrid Bound to a Data Set
When there's a data set on the form, it's easy to bind the data grid to it. You set the data grid's DataSource property in the Property Browser and fill the data set when the form is loaded. To do this, you use the data adapter:
Sub DownloadsForm_Load(sender As Object, e As EventArgs) _
Handles DownloadsForm.Load
SqlDataAdapter1.Fill(downloadsDataSet1)
End Sub
This is only a scratch on the surface of what can be done with data binding in general and the data grid
|
Multithreaded
|
Deployment
When you've got your application just how you like it, all arranged and
Of course, the problem with both of these techniques is that as soon as you share your application, that's when you find the crushing bug that, when the moon is full and the sun is in the house of Orion, causes bad, bad things to happen. When problems come up, you need to remember who received your application so that you can let them know to install the new version before the existing version formats C: or resets your boss's Minesweeper high scores. Of course, all of this explains why your IT department
The Web application deployment model is so simple, there is no deployment. Instead, whenever users surf to the Web application in the morning, they get the version that the IT department uploaded to the server the night before. That deployment model has never been available out of the box for Windows applications. Until now. At this point, you should stop reading and try the following:
You've just used the
no-touch deployment
(
NTD
) feature of .NET to deploy your WinForms application like a Web application, except that it's a real Windows application complete with full
For the details of deploying WinForms applications and controls over the Webincluding hosting WinForms controls on a Web page, application deployment, versioning, caching, and most importantly, securityturn to Chapter 15: Web Deployment. |