BUG: The last-modified cell of a DataGrid control loses changes when you close a form (833032)
The information in this article applies to:
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Professional Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
SYMPTOMSWhen you close a form that contains a DataGrid control as the active control without moving the focus from the
last cell that you edited, you lose the changes that you made to the last cell
that you edited.CAUSEBecause the DataGrid control is not a container control, the DataGrid control does not raise the Leave event. Therefore, the DataGrid control does not update the corresponding database with the
changes that you made to the last cell that you edited, and you notice the
behavior that is mentioned in the "Symptoms" section.WORKAROUNDTo work around this bug, follow these steps:
- Start Microsoft Visual Studio .NET
- Open the form that contains the DataGrid control.
- In the Form1_Closing event handler, add
the following code before the code that updates your database with the changes
that you made:
DataGridColumnStyle cStyle =
dataGrid2.TableStyles[dvOrderDetails.Table.TableName].GridColumnStyles[dataGrid2.CurrentCell.ColumnNumber];
dataGrid2.EndEdit(cStyle, dataGrid2.CurrentCell.RowNumber, false);
dvOrderDetails.Table.Rows[dataGrid2.CurrentCell.RowNumber].EndEdit();
STATUSMicrosoft
has confirmed that this is a problem in the Microsoft products that are listed
in the "Applies to" section of this article.REFERENCESFor additional information about DataGrid objects, DataGrid in-place editing, and form events, visit the
following Microsoft Web sites:
Modification Type: | Major | Last Reviewed: | 4/26/2006 |
---|
Keywords: | kbvs2002sp1sweep kbWindowsForms kbDataAdapter kbbug KB833032 kbAudDeveloper |
---|
|