ComponentOne LiveLinq > Getting Started with LiveLinq > Hierarchical LiveLinq Binding > Traditional WinForms Implementation |
Our sample application will consist of the following elements:
This is what the final application will look like:
The basic implementation is simple, since Visual Studio handles most of the data binding related tasks automatically. In fact, the entire application can be written without a single line of code.
Here are the steps:
At this point, the application has access to the data and it has controls to show and edit the data. To connect the controls to the data, follow these steps:
The final step is to select each data bound control and bind it to the BindingSource component:
For the ComboBox, set the following properties:
C1DataSource bindingSource1
DisplayMember CategoryName
ValueMember CategoryID
For the DataGridView, use the drop-down editor in the property grid to set the C1DataSource property to FK_Products_Categories, the item that appears under bindingSource1 and represents the products under the currently selected category. The image below shows what the drop-down editor looks like just before the selection is made:
Finally, select each of the TextBox controls and use the drop-down editor in the property window to bind the Text property to the corresponding element in the currently selected product. For example:
Repeat this step to bind the other TextBox controls to the UnitPrice, QuantityPerUnit, and UnitsInStock fields.
The application is now ready. Run it and notice the following:
This is the traditional way of doing data binding in WinForms. Visual Studio provides rich design-time support and tools that make it easy to get applications started. Of course, real applications typically require you to add some code to implement specific logic.