KB Article T934742
Visible to All Users

DevExpress WinForms Troubleshooting - Grid Control

Cheat Sheets, Best Practices and Troubleshooting


This article includes information on most common issues you may encounter when working with Data Grid (Grid Control) and the ways to resolve them.

Known Issues

Issue 1: Grid Control doesn't display or update data. Data cannot be edited.

Solution

Based on our experience, most of the issues related to showing, updating and editing data in the Grid lie at the data source level. Please refer to the following article to learn about common data binding-related cases: DevExpress WinForms Troubleshooting - Data Binding Issues.
Pay special attention to the Issue 2 and Issue 3 sections in the Data Binding Issues articles. If the information in these sections doesn't help, we recommend that you try the steps described at the beginning of the Data Binding Issues article.

Issue 2: Data is not saved into database.

Solution

When you edit data in Data Grid, the control saves changes to the underlying data source (e.g., DataTable or BindingSource), but not to the database (see DevExpress WinForms Cheat Sheet - Database Interaction). You need to manually save data to the database at the data source level. Please refer to the following article for more information: Post Data to an Underlying Data Source.

If the issue persists, verify that it doesn't occur with the standard components (for example, you can test your code with the standard DataGridView control). Finally, ensure that your application does not throw exceptions. Please refer to the following help article for details: How to investigate an issue and determine why it occurs in your project.

Issue 3: Detail data is not shown in master-detail mode.

Solution 1

Specify a correct level name. Detail Views are retrieved by level names that must match real master-detail relation names (or collection property names if your pattern Views display collection property data). Please refer to the following help articles for details:
Master-Detail Relationships
Working with Master-Detail Relationships in Code

Solution 2

Confirm that detail data is populated. To achieve this, go back to the Issue 1 section of this article.

Solution 3

Enable the BaseView.DataController.AllowIEnumerableDetails option before you bind the Data Grid to a data source. This is necessary when you have collection properties of the IList<T>, ICollection<T> and IEnumerable types. Such properties are not recognized as collection properties by default.

Issue 4: Cannot obtain a detail View's data. A detail View's method does not work.

Solution

Make sure that you are working with the real view, not a pattern view. Please refer to the following help article to learn more about this concept: DevExpress WinForms Cheat Sheets - XtraGrid Master-Detail Mode.

Issue 5: The designed Grid's layout changes at runtime. A property set at design time is not in effect at runtime. The Grid's layout changes after restoring a saved layout.

Solution

This issue usually occurs when an old Grid layout is restored in your code. Look for RestoreLayoutFrom~ method calls in your code.

In addition, make sure that you do not change the Grid's properties in your code. Check that your event handlers or other code do not affect the Grid's layout. For this, use one of the following approaches:

  • Handle the BaseView.Layout event. Since this event fires immediately after a View’s layout has been changed, you can put a breakpoint into this event and check the call stack to find code that changed the View's layout.
  • Comment out your code line by line to locate code that changed the View's layout.

Issue 6: The Grid shows a red cross.

Cause

The Grid shows a red cross when an unhandled exception occurs during painting. The following may cause the exception:

  • Incorrect use of multi-threading.
  • Code performed in custom draw event handlers.

Solution

Issue 7: An exception occurs.

Solution

If the exception's description doesn't allow you to determine why the issue occurs, do the following:

Issue 8: Custom painting is not in effect or custom information is painted incorrectly.

Solution

Check whether you are using DirectX rendering and refer to the Custom drawings are not in effect section of the How to investigate an issue and determine why it occurs in your project help article.

Issue 9: The Grid or form that contains it operates slowly.

Solution

Refer to the following help article: DevExpress WinForms Troubleshooting - Performance Issues.

Issue 10: The Grid operates incorrectly at design time.

Solution

Refer to the Issue 3, Issue 4 and Issue 7 sections of the following help article: DevExpress WinForms Troubleshooting - Visual Studio Design Time Issues. If you are using a custom Grid descendant, you can start with replacing it with the standard GridControl instance.

Issue 11: The Grid doesn't print or export elements painted in a custom manner.

Solution

Refer to the following help article: Is custom drawing ignored when printing or exporting?

Issue 12: A new record cannot be added to the Grid using New Item Row/Card and entered values disappear after a cell loses focus.

Solution

Make sure that the Grid's data source allows new records to be added. If the Grid is bound to a list of objects, make sure that an object has the default parameterless constructor. Check if the data source meets the Common Requirements described in the following help article: Add and Remove Rows.

Issue 13: The Grid's layout is broken after you restore a previous layout, e.g. column width is incorrect.

Solution

Most likely, the issue occurs because the Grid is not completely initialized when its layout is restored. Try calling the ForceInitialize method before you restore the layout.

The issue is not on the Known Issues list:

If the issue you faced is not described above, you can always perform the following steps:

Steps

  • If you use a custom Grid descendant, replace it with the standard GridControl instance and check if the issue is resolved.
  • Replace a GridControl instance with its standard .NET DataGridView counterpart and check if the issue still persists.
  • Look for similar issues, errors, and solutions on the web, Stack Overflow, or in our Search Engine.
  • If you can't find any information about the error on the web or in our Support Center, please create a new ticket in our Support Center. Please share as much information as possible (performance profiler results, steps to reproduce, a project where the issue is reproducible). This information will help us determine the cause of the issue in the fastest and most straightforward way.

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.