DataGridView, FormattingException, DataError, and PreferredSize ~ Auto-Sizing Issue

Alright so I think I now have a good handle on this now. If you are using auto sizing for your columns, you might run into a formatting exception. The error you get says that you can handle the error in the DataError event.

If you start error handling within that event you might notice that you get a context of 5 which says it is either a Formatting or PreferredSize data error context. To quote MSDN:

A data error occurred when calculating the preferred size of a cell. This value indicates that the DataGridView failed to calculate the preferred width or height of a cell when programmatically resizing a column or row. This can occur if the cell failed to format its value.

Cancel the event by issuing the following e.Cancel = True after checking to make sure that the DataGridViewDataErrorEventArgs (e) has the context of 5 for PreferredSize