n this article, I'll explain how the Data Sources Window in Visual Studio 2005 will enable you to extend the list of controls supported for Drag Once Databinding. I'll show you how to create a PhoneBox control and an AddressBlock UserControl.
In the September/October 2004 issue of CoDe,
I discussed how developers can use Windows Forms to create a Data Bound form with a single drag-and-drop action. With Visual Studio 2005, this works on all our client platforms including Windows Forms, Visual Studio Tools for Office, Devices, and even Microsoft Reports using Reporting Services. In this article, I'll explain how you can use Drag Once DataBinding with your own set of controls.
First, a Quick Recap
Using the new Data Sources Window, developers can add several different types of Data Sources including databases using typed DataSets, business objects, and XML Web services. The Data Sources Window displays the "schema" of these objects. If you have a DataSet with a list of DataTables, you can navigate through the DataSet and drag your tables or columns to your form. If you have an object with public properties, you can drag away. As a result, Visual Studio creates the specific controls and labels; named and databound. Simply hit F5, and away you go.
For more detail, you can see the full article online.
So now that you've got the basic idea down, and you've played with all the new controls that ship with Visual Studio 2005, you want to plug in your own control. How does this all work?
To get a feel for how the model works, let's look at customizing the controls that we'll be shipping in the box.
|You're probably wondering, "Will my 1.1 controls work with Drag Once Databinding?" Maybe. In order for VS 2005 Drag Once DataBinding features to figure out what property to bind to, you may need to crack open the code and add one or more of the binding attributes. Early on, we talked with component vendors and they plan to quickly release updated controls with the new attributes.