Troubleshooting: Edit Cell Values
- 4 minutes to read
This topic contains a list of the most common cell editing issues and describes how you can resolve them.
The Entire View, Certain Columns, or Certain Cells Are Read-Only
Problem
You cannot edit cell data in the entire view, certain columns, or certain cells.
Solution
Check that the following conditions are satisfied:
- Columns are bound to data source fields. Use either ColumnBase.FieldName or ColumnBase.Binding to bind your column to a data source property.
- The data source property has a public setter.
If you set a column’s ColumnBase.Binding property, the binding’s
Mode
should beTwoWay
:<dxg:GridColumn Header="Id" FieldName="col1" Binding="{Binding Path=Id, Mode=TwoWay}"/>
If you set a column’s
Binding
property, ColumnBase.FieldName should not use an existing property name. See the “INCORRECT” and “CORRECT” examples below.<!--INCORRECT--> <dxg:GridColumn Header="Id" FieldName="Id" Binding="{Binding Path=Id, Mode=TwoWay}"/> <!--CORRECT--> <dxg:GridColumn Header="Id" FieldName="col1" Binding="{Binding Path=Id, Mode=TwoWay}"/> <!--CORRECT--> <dxg:GridColumn Header="Id" Binding="{Binding Path=Id, Mode=TwoWay}"/>
Ensure that you did not change settings or write code that disabled data editing functionality. Review your implementation and see if you use any of the techniques from the following topic: Make Cells Read-only or Disable Editing.
If you use the GridControl in Server Mode, note that the following server mode data sources are initially read-only: WcfInstantFeedbackSource, EntityServerModeDataSource, and LinqServerModeDataSource. To enable data editing functionality, implement CRUD operations as illustrated in the following example: Implement CRUD Operations in the WPF Data Grid.
Virtual Source components support data editing in v20.1 and higher. Refer to the following help topic for more information: Enable Data Editing.
The Grid Control Doesn’t Create Columns for Collection Properties or Such Columns are Read-Only
Problem
The GridControl does not generate columns for collection properties. Such properties are usually used to populate detail grid controls.
You can bind a column to a collection property manually. However, you need to take additional steps to enable data editing.
Solution
Use one of the following solutions:
Use the ColumnBase.Binding property to bind columns to collection properties.
Use Editors.BaseEdit descendants that support multiple selection. Examples include ComboBoxEdit, LookUpEdit, and ListBoxEdit. Define them either with EditSettings or ColumnBase.CellTemplate. Refer to the following help topic for more information: Multiple Selection in ComboBoxEdit, LookUpEdit, and ListBoxEdit.
Note
ColumnBase.FieldName can only operate with an
Object
type. ChangeList<T>
toObject
in your data item. If the property isList<Object>
, use the ColumnBase.Binding property. For other collection types likeList<string>
, use a custom converter with the ColumnBase.Binding property to convert collection objects.Implement a ColumnBase.CellTemplate with a custom editor. In this case, we do not recommend to use non-DevExpress editors.
Cell Value Is Different in Edit and Display Modes
Problem
Cells in your GridControl display different values in edit and display modes.
Solution
See the Works in Edit Mode column in the table from the Format Cell Values help topic.
Cells Are Empty
Problem
Cells in your GridControl display no values. The image below shows a common scenario where you see editor borders in cells but no content.
Solution
Use one of the following solutions:
If you use ColumnBase.CellTemplate with our editors, make sure that you set their
Name
toPART_Editor
. In this case, the GridControl automatically adjusts its appearance and synchronizes the editor with the source field specified by the ColumnBase.FieldName or ColumnBase.Binding properties.Make sure that your columns have a correct ColumnBase.FieldName property. You can use Snoop or similar tools to analyze the application’s visual tree. The video below shows Snoop in action.
Refer to the following help topic for more information: How to use the Snoop utility to inspect my WPF application and debug issues.
If you use ComboBoxEdit or LookUpEdit as in-place editors in your GridControl, make sure that you properly specified the LookUpEditBase.ValueMember and LookUpEditBase.DisplayMember properties.
If you specify your own in-place editor for a column/cell, check whether your application reports any binding errors in Visual Studio’s Output window. If you see errors, fix the binding path. Refer to the following help topic for additional information: How to build binding paths.
If you use unbound columns, make sure that you correctly handle the CustomUnboundColumnData event or specify the ColumnBase.UnboundExpression property. To check the current cell value, set a breakpoint in the event handler for the CustomUnboundColumnData event. To check the current value of the ColumnBase.UnboundExpression property, use the Snoop tool.