In This Topic
Data binding lets you populate the control with data by fetching it from an underlying data source. InputPanel supports data binding at design-time as well as at run-time. The control supports data binding to most of the commonly used data sources such as ObservableCollection, IList, List, Array, BindingSource, ADO.NET objects such as DataSet, DataTable etc. On binding InputPanel to a data source object at design time, the control is automatically populated with components used to view and edit the data in the data source, including keyboard accelerators.
Binding at Design Time
- In the design view, select the C1InputPanel control and click smart tag to open the C1InputPanel Tasks menu.
- Click the Choose Data Source drop down button and select Add Project Data Source... option to open the Data Source Configuration Wizard.
- On Choose a Data Source Type page, select Database and click Next.
- On Choose a Database Model page, select Dataset and click Next.
- On Choose Your Data Connection page, click New Connection to open the Add Connection dialog.
- Against the DataSource field, click Change... button to open the Change Data Source dialog.
- Select Microsoft Access Database File and click OK to return to the Add Connection dialog.
- Against the Database file name field, click Browse and navigate to the database file. Provide the User name and Password, if required to connect to the database file. This example uses C1NWind.mdb file located at the following location by default:
\Documents\ComponentOne Samples\Common
- Click Test Connection to make sure that you have successfully connected to the database or server and click OK.
- Click OK again to close the Add Connection dialog box.
- Click Next to continue. A dialog box will appear asking if you would like to add the data file to your project and modify the connection string. Choose the appropriate option as per your requirement.
- Save the connection string in the application configuration file by checking the Yes, save the connection as box and entering a name.
- Click Next to switch to the Choose Your Database Objects page.
- Choose a table, say Employees from the Tables node and click Finish.
The above steps add a dataset and connection string to your project. Also, Visual Studio automatically creates the following code to fill the dataset:
See Also