VS Bug on FormClosing datagridviewcomboboxcell value is not valid
05-Sep-1111 2 Comments
Error message may be “Field called xxx does not exist”
Try this on Form closing
Private Sub frm_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.MyGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None
End Sub
I would hazard to suggest thatVisual Studio does not dispose of the datagridview in the correct sequence
This sometimes occurs when my personal code > SetUpDataGridView may programmatically set the AutoSizeRowsMode.
—–
This link http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/88c3adee-ed2a-41ee-9407-c3314588e08a/
Suggests it may be something to do with autosize, when there is a combobox created. The order of creation and setting may be important.
“If you autosize the column but have not provided the combo box column with a valid datasource or you haven’t yet added items to the combo box column’s items collection then you’ll get this error at startup because autosizing requires the cell’s FormattedValue to be requested. Requesting the FormattedValue of a combo box cell is where the check is done that may raise the data error exception you are seeing.
Set the autosize mode after you fill the combo box and things should be ok.
Mark Rideout – DataGridView Program Manager – Microsoft”
Or create the comboboxcolumn then clear the autosize modes > run > re-set the autosize mode.
Or programattically set the autosize after form has designer InitialiseComponent code has loaded.