Archive for August, 2009

C# DataGridView not updating cell if EditOnEnter property set

Monday, August 3rd, 2009

While programming a little utility, I came across an issue programmatically updating the value of a cell in a DataGridView (.NET 3.5, Visual Studio 2008).  Before setting the EditOnEnter property, the cell would visually update on the EndEdit() call, however, this broke when I set the EditOnEnter property (I presume because this property sets the grid in a perpetual edit and thus ignores the EndEdit() call).  The solution I found was to call RefreshEdit().  Info from Microsoft is here.  The basic info is RefreshEdit() refreshes the display of a cell even during editing.