[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Collapse]Get Started With Data Grid and Views
     [Expand]Appearance and Conditional Formatting
     [Expand]Data Editing
     [Expand]Hit Information
     [Collapse]Data Binding and Working with Columns
       Tutorial: ADO.NET Data
       Tutorial: Working with Columns in Code
       Tutorial: Unbound Columns
       Tutorial: Create and Manage Columns at Design Time
       Tutorial: Entity Framework Data
       Tutorial: Create and Manage Data in Code and Apply Data Annotation Attributes
       Tutorial: Large Data Sources and Instant Feedback with Server Mode
     [Expand]Grid View - Columns, Rows and Cells
     [Expand]Banded Views
     [Expand]WinExplorer View
     [Expand]Tile View
     [Expand]Filter and Search
     [Expand]Split Presentation
     [Expand]Row Preview Sections
   [Expand]Data Binding
    Unbound Columns
   [Expand]Data Editing and Validation
   [Expand]Filter and Search
   [Expand]Focus and Selection Handling
    Format Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
   [Expand]Batch Modifications
    Hit Information
    Popup Menus
   [Expand]Save and Restore Layout
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Tutorial: Create and Manage Columns at Design Time

This walkthrough is a transcript of the Create and Manage Columns at Design Time video available on the DevExpress YouTube Channel.

In this tutorial, you will learn what columns are created by the grid automatically, how to use the grid's integrated designer to manage the columns collection and how to bind columns to data fields.

Expanded Starting Point

Start with a project that already has a grid control bound to a data source. As you can see, this data source is the Products table from the NorthWind database with just a few fields selected.

Expanded Default Behavior

Each time you bind your grid control to the required data, columns are created automatically - one for each data field in your data source. Thus, you will see that the grid now has the same columns as the fields you just saw in the bound data source.

Expanded Managing Columns Collection Using the Grid Designer

To add or remove columns, use the Grid Designer. Switch to the Columns tab to see two lists. The list on the left hand side displays data fields available in the bound data source and you can toggle this list's visibility. The list on the right hand side is the grid View's current column collection.

  • Removing Columns

    If you remove a column, the corresponding field is highlighted using bold font.

  • Creating Bound Columns

    You can then drag that field onto the columns list to automatically create a bound column.

  • Creating and Manually Binding Columns

    You can also create a column and then manually specify its name that will be used to access it in code. To bind it to a data field, use the GridColumn.FieldName property.

  • Retrieving All Data Fields

    The Retrieve Fields button can also come in handy. It clears the column collection and then creates bound column for every data field, much like when you first bind the grid to data. To illustrate this, modify the query so it includes data fields that were not originally used. The grid View's column collection remains the same.

    Switch to the Columns section of the Grid Designer and click the Retrieve Fields button. All of newly added fields are now retrieved and a grid column for each of them is created.

    Run the application and see that all columns have been created, including those just added to the data source.

Expanded See Also

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