Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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
   [Expand]Getting Started
   [Collapse]Binding to Data
    [Expand]Server Mode
     Grid Control Binding Specifics
     Posting Data to a Connected Database
     Unbound Columns
     Binding to Entity Framework Models
     Binding via Data Source Configuration Wizard
     Fluent API Support
     Member Table: Data Binding
     Tutorial: ADO.NET Data
     Tutorial: Create and Manage Columns at Design Time
     Tutorial: Create and Manage Data in Code and Apply Data Annotation Attributes
     Tutorial: Entity Framework Data
     Tutorial: Unbound Columns
     Tutorial: Working with Columns in Code
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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

How would you rate this topic?​​​​​​​