Browse DevX
Sign up for e-mail newsletters from DevX


Drag Once DataBinding with Custom Controls

Visual Studio 2005 will ship some great new controls, but suppose you want your own control to play in the Data Sources Window? To do that, you need to set up a new data source using the new binding attributes.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

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.

Fast Facts
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.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date