Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Collapse]Grid View Data Layout
    [Collapse]Columns and Card Fields
      Accessing and Identifying Columns
      Creating Columns and Binding Them to Data Properties
      Hiding and Displaying Columns and Bands
    [Expand]Bands
    [Expand]Rows and Cards
    [Expand]Nodes
     Data Cells
     Best Fit
     Compact Mode
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Selection
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Drag-and-Drop
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Creating Columns and Binding Them to Data Properties

When the DXGrid is bound to a data source, you need to create columns and bind them to data properties. There are two ways to do this:

  • Automatically create columns for all properties in a data source

    The grid automatically generates columns for all properties in the data source. The order of columns is the same as the order of properties in the data source. The grid's GridControl.Columns collection is populated at runtime. This collection is empty at design time.

    This behavior is controlled by the DataControlBase.AutoGenerateColumns property. One of the AutoGenerateColumnsMode enum values is used to set this property. After all columns have been created and added to the collection, the grid fires the DataControlBase.AutoGeneratedColumns event.

    This can be useful, for instance, when the structure of the underlying data source is unknown (e.g. switching between data tables).

  • Create columns and bind them to data manually

    Manually create all the necessary columns, add them to the GridControl.Columns collection and bind them to data source properties using their ColumnBase.FieldName or ColumnBase.Binding property.

Expanded Creating and Binding Columns at Design Time

To access the grid's GridControl.Columns collection, invoke the Columns edit form:

This form allows you to add, delete, access and customize column settings, and perform other common collection management tasks.

The following code shows how to create columns in XAML:

  • using the GridColumn.FieldName property.

  • using the GridColumn.Binding property.

Note

When working with data structures that contain Dynamic Objects, use the ColumnBase.Binding property instead of ColumnBase.FieldName.

Note

Columns that are bound using the ColumnBase.Binding property might work more slowly than columns that use the ColumnBase.FieldName property.

Expanded Creating and Binding Columns at Runtime

The following example shows how to create a column and bind it to a data property:

  • using the GridColumn.FieldName property.

  • using the GridColumn.Binding property.

To create columns for all properties in a data source, call the DataControlBase.PopulateColumns method. This method clears the grid's GridControl.Columns collection, and re-populates it with columns/card fields that correspond to all properties in a data source.

Expanded See Also

Is this topic helpful?​​​​​​​