Skip to main content
A newer version of this page is available. .

Lesson 1 - Add a GridControl to a Project and Bind it to Data

  • 2 minutes to read

This tutorial demonstrates how to add a GridControl to your project and bind the control to a database:

GridControl Tutorial Result

  1. Download the following blank sample project with an adjusted database connection:

    View Example

  2. Create a ViewModel template that implements ViewModelBase:

    using DevExpress.Mvvm;
    
    namespace WPFBlankAppWithDatabase {
        public class ViewModel : ViewModelBase {
    
        }
    }
    
  3. Add the GridControl to a project.

    Tip

    If you get the DevExpress products from a NuGet feed instead of the Unified Component Installer, the toolbox does not contain DevExpress controls until you add the corresponding NuGet package.

    Go to Tools | NuGet Package Manager | Manage NuGet Packages for Solution and add the DevExpress.Wpf.GridControl NuGet package.

  4. Build the solution to make the ViewModel class visible in the window’s Quick Actions.

  5. Select the GridControl and invoke its Quick Actions. Launch the Items Source Wizard.

    Items Source Wizard

  6. Select the data source.

    Items Source Wizard - Data Source

    Select the Order table.

    Items Source Wizard - Table

    Select the Simple Binding model.

    Items Source Wizard - Model

    Ensure that the CRUD options are enabled.

    Items Source Wizard - Settings

    Select the ViewModel option to generate data binding code in the ViewModel class. Verify that the ViewModel class is selected as the View Model.

    Items Source Wizard - Boilerplate Code

  7. Run the project. The GridControl generates columns for all fields from a bound data source:

    GridControl Tutorial Result

See Also