ComponentOne Input for WinForms
Data Binding
Using the C1Input Controls > Data Binding

C1Input controls can function both in unbound and in bound mode. In bound mode, a control’s Value is bound to a data source field.

C1Input controls support data binding to all .NET data sources. This includes ADO.NET data source objects such as DataTable, DataView and DataSet, and also DataObjects components such as C1ExpressTable, C1ExpressView, C1ExpressConnection, C1DataView, C1DataTableSource and C1DataSet.

For details about creating ADO.NET data source objects, please refer to the .NET Framework documentation.

For details about using DataObjects, see the C1DataObjects documentation included in the ComponentOne Studio Enterprise. DataObjects is a data framework, a part of ComponentOne Studio Enterprise, enhancing ADO.NET in many ways.

To bind a C1Input control to a date source field:

To bind a C1Input control to a data source field:

  1. Assign the data source object to the control's DataSource property
  2. Then assign a field of the data source object to the control’s DataField property.

    You can set the DataSource and DataField properties in code as well as in the designer. At design time, you can select the data source object and its field from the lists of available data sources and their fields provided by the DataSource/DataField property combo boxes.

  3. Set the DataType property.

    After you bind the control to a data field, the DataType property is automatically set to the data type of the field it is bound to. In most cases, this setting is what you need. However, sometimes you need different types for the control and the field. For example, you might have a string field containing dates. In such cases, you can set the DataType property after binding and use the BindingFormatting/BindingParsing events to convert data to/from the control’s DataType when it is written from/saved to the data source.

The DataSource/DataField properties are used to bind the Value property of the control to a data source field. The Value property is the main property of a C1Input control. It holds and returns a value with of a specific data type. In addition, you have the freedom to bind other properties of the control to other data sources and fields, as in any other WinForms control, using the DataBindings property. This functionality is not C1Input-specific; it is supported by the .NET Framework for all controls.

Caution: Do not use properties other than the Value property under DataBindings to bind the control’s value to a field, use the DataSource and DataField properties instead (or use Value in DataBindings). For example, although it is possible to bind the Text property to a field, the result will not be the same as binding the Value property.
See Also