This documentation is archived and is not being maintained.

How to: Display Data on a Form

Visual Studio 2008

Displaying data on a Windows Form is easy with Visual C# Express Edition. You can connect to a database in SQL Server Compact 3.5 by using the Data Sources window, and then drag data-bound controls to a Windows Form.

To display data on a form

  1. On the File menu, click New Project.

  2. In the New Project dialog box, click Windows Application, and then click OK.

    A new Windows Forms project opens.

  3. Add a connection to the sample database named Northwind.sdf as described in How to: Connect to a Database (C#). In step 12, select the check box for Customers and then click Finish.

  4. On the Data menu, click Show Data Sources.

    The Data Sources window opens.

  5. In the Data Sources window, expand NorthwindDataSet, and then click the Customers table.

  6. Click the drop-down arrow next to the Customers table and then click Details.

  7. Drag the Customers table to Form1.

    A series of Label and TextBox controls are added to the Windows Form.

  8. Press F5 to run the project.

  9. When the application opens, click the Move next button on the customersBindingNavigator control at the top of the form.

    The Windows Form moves to the next record in the dataset every time that you click the Move next button.