Bind a DataGrid to a Dataset

This exercise describes how to add a DataGrid to a form and bind it to a dataset:

  1. Click and drag a DataGrid from the Toolbox to the Design Sheet:
  2. To bind the DataGrid to the rows and columns of a dataset, select Set Data Binding from the control drop-down menu:
  3. Choose the dataset to bind to the DataGrid:
  4. The binding is shown on the DataGrid:

    If the dataset binding string is truncated on smaller controls, to see the full string you can hover the mouse over the binding icon.

    Note:

  5. Save your changes and click Run to run the form:
  6. The DataGrid displays the rows and columns in the bound dataset.

  7. Click inside the DataGrid to give it focus. You can then use the keyboard arrow keys to navigate up and down between rows, navigate left and right between columns. You can also use keyboard shortcuts to move to the last or first record.
  8. A NavigationBar allows you to navigate the DataGrid (and more) using mouse clicks. See: Navigate a Dataset