DataGridView not saving state
I've ran into a subtle but problematic issue with the DataGridView saving a new row. I have a databound dgv stored in a UserControl and when the user enters values into a field, the values are not updated when the UserControl is closed (removed from the form). To save time I won't do into an explanation on why the dgv resides in a UserControl but I promise that there is a legitimate reason. Does anyone know how to force the dgv to save state of the new row being edited? If the user enters values into a new row and moves to another row, the state is saved but I can't depend on that happening in a real world situation. I have tried: dgv.NotifyCurrentCellDirty(), dgv.EndEdit() etc and nothing is working.
Here is how to replicate this issue. (Maybe a bug)
Try dropping a dgv that is bound to a dataTable into a UserControl. Now drop the UC inside a Form. Have a MenuStrip item that can be clicked to remove the UserControl from the form. Run the application and add some text to the new row at the bottom. Now without moving the cursor to another cell, click the MenuStrip to remove the UserControl. Now run the program again and the new row's state will not be saved. Enter some text again into the new row at the bottom and close the Form this time. The new row should save state this time.
Thanks for any help that can be provided.
Richard