Super Charge Your Forms-based Apps with Advanced Data Binding
Data binding can be used for more than just data. When you want to change the value of controls based on the state of other controls, data binding is the right solution.
by Sanjay Shetty
November 6, 2003
hen you think of using data binding in .NET it's always to structured data sources such as a DataSet, array, list etc. But in reality, you aren't limited to data residing in databases. Using data binding in Windows Forms, you can bind to almost any structure that contains data. You can bind to an array of values that you calculate at run time, that you read from a file, or that derive from the values of other controls. This article will focus on binding properties of one control to properties of another control.
In traditional data binding, you typically bind the display property (for example, the text property of a TextBox control) to your data source. With the .NET framework, you also have the option of setting other properties via binding as well. In fact, you can bind any property of any control to your data source. You might use binding for:
Setting the graphic of an image control.
Setting the background color of one or more controls.
Setting the size of controls.
Figure 1. Windows Form with Controls: The Panel on this form changes behavior based on the status of the CheckBoxes.
In other words, data binding becomes an automatic way of setting any runtime-accessible property of any control on the form.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!