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
   [Expand]Data Binding
   [Collapse]Views
    [Collapse]Grid View
      Columns
      Unbound Columns
      Rows
      Cells
     Banded Grid Views
    [Expand]Card and Layout Views
     WinExplorer View
    [Expand]Tile View
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Filter and Search
   [Expand]Summaries
   [Expand]Focus and Selection Handling
    Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
    Scrolling
   [Expand]Batch Modifications
   [Expand]Hit Information
    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]ASP.NET Core 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]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Columns

Expanded Automatic Column Generation

When you bind a Data Grid to a data source, the control automatically generates a column for each found data field. For code-first data sources (e.g., Entity Framework models), you can mark a property with the Display attribute and disable its AutoGenerateField parameter to skip generating a column for this property. The "Display" attribute in the code below prevents a Data Grid from generating an "Additional Info" column.

You can utilize many more attributes to re-arrange columns, modify captions of their headers, change their default in-place editors, etc. Refer to the Data Annotation Attributes article to learn more.

In case you have replaced a previous data source with a new one, the Data Grid will not automatically re-generate columns. You need to do that manually by invoking the Data Grid Designer and clicking the "Retrieve Fields" button within the "Columns" tab.

To do the same in code, call the BaseView.PopulateColumns method either directly after changing a data source, or on the GridControl.DataSourceChanged event.

Expanded Add and Remove Columns Manually

Columns associated with data fields declared in a data source are called bound columns. To add such columns manually, invoke the Data Grid designer, switch to the "Columns" tab and click the "Show Field List" button, then drag a data field into the column list. Data fields that have no corresponding grid columns are highlighted with bold text.

You can also utilize the "Add Column" and "Insert Column" buttons on the same designer page. In this case, you need to set every column's GridColumn.FieldName property manually. Otherwise, a column is unbound and does not receive cell values from a data source.

To remove a column, utilize the "Remove Column" designer button, or click a column header at design time and press the "Delete" key.

Expanded Column Header

To modify a column header caption and add an image, select a column at design time and invoke its smart tag. If a column has no caption assigned, the column generates its caption based on the name of a related data field.

Related API

Expanded Hide Vertical Column Borders

You can hide column and row borders by disabling the GridOptionsView.ShowVerticalLines and GridOptionsView.ShowHorizontalLines settings.

Expanded Column Width

By default, the Data Grid squeezes all its columns into its current client area. End-users can resize columns except for the last one and total column width cannot exceed the width of a parent View.

Disable the GridOptionsView.ColumnAutoWidth property to allow grid columns to transcend the View bounds. A horizontal scroll bar is displayed automatically if columns occupy more space than the View provides.

Related API

Expanded Best Fit

To ensure a column (or all the View columns) has enough width for its cells to entirely display their content, end-users can right-click a column header and choose the "Best Fit" (or "Best Fit (all columns)") option.

Related API

Expanded Auto-Fill Column

A grid column assigned to the GridView.AutoFillColumn property automatically resizes to fill in any free space a View provides. In the animation below, the auto-fill column is "Address".

Expanded Fixed Columns

Modify a column's GridColumn.Fixed to anchor it to a left or right View side. Fixed columns remain always visible while end-users scroll the View horizontally.

The Fixed Columns demo illustrates how to supply grid columns with custom popup menus that allow users to anchor columns at runtime.

Expanded End-User Capabilities

By default, end-users can do the following:

Expanded Identify and Access Grid Columns in Code

To retrieve specific columns, utilize the following API:

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