ComponentOne List for WinForms
In This Topic
    Step 2 of 3: Binding the List for WinForms Application to a DataSet
    In This Topic

    In the last step you added the C1List control to your project and created a simple list application. In this step you'll bind the C1List control to a DataSet. Complete the following steps:

    1. Click C1List1's smart tag to open the C1List Tasks menu, select the drop-down arrow next to Choose Data Source, and click Add Project Data Source to open the Data Source Configuration Wizard.
       
    2. The Data Source Configuration Wizard appears with a Database data source selected. Click Next to select a database connection.
    3. Click the New Connection button to locate and connect to a database.
    4. The Add Connection dialog box opens. Click the Browse button and locate the C1NWind.mdb file. Select it and click Open.
    5. Click the Test Connection button to make sure that you have successfully connected to the database or server and click OK in the dialog window confirming the connection succeeded.
    6. Click OK in the Add Connection dialog box to add the next connection and return to the Data Source Configuration Wizard. The new string appears in the data connection drop-down box.
    7. Click the Next button 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. Click No.
    8. In the next window, note that the Yes, save the connection as checkbox is checked by default and "C1ListDemoConnectionString" has been automatically entered in the text box. Click Next to add tables and fields to the DataSet.
    9. In the Choose Your Database Objects window, you can select the tables and fields that you would like in your dataset. Select the Composer table, the fields within the Composer table should all be selected as well.

      The DataSet is given a default name in the DataSet name textbox.
    10. Click Finish to exit the wizard. The DataSet, BindingSource and TableAdapter now appear on your form.
    11. Double-click the form. Notice that Visual Studio has added the following code to the Form_Load event:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Me.ComposerTableAdapter.Fill(Me.C1ListDemoDataSet.Composer)
      

      To write code in C#

      C#
      Copy Code
      this.ComposerTableAdapter.Fill(this.C1ListDemoDataSet.Composer);
      

    Run the program and observe the following:

    Notice that the data from the Composers table is reflected in the list:

    List for WinForms retrieves the database schema information from the DataSet and automatically configures itself to display all of the fields contained in the database table. Note that the field names are used as the default column headings.

    You have successfully completed binding List for WinForms to a DataSet. In the next step you will customize the C1List control's appearance settings.