DefaultCellStyle.NullValue or setting standard error graphic to Bitmap
i have a databound DGV and need to replace the standard error graphic to my own Image so when the user clicks add new the ugly red cross icons do not show
i have read the info on MSDN and done some google searches as well as a lot of playing around with code but cant seem to get it to work
Source for this http://msdn.microsoft.com/en-AU/libr...=vs.85%29.aspx
So this is what i can understand so far and what i have tried
according to MSDN to change the standard error image you set the DataGridViewCellStyle.NullValue property for this cell style object to a null reference
So i tried
Code:
ProfilesDataGridView.DefaultCellStyle.NullValue = vbNull
However i get this error
Quote:
the following exception occured in the datagridview:
system.formatException: Formated value of the cell has wrong type
BUT all that just disables the standard error image i think?
I need to know how to change the image from icon to bitmap so i can use my own png image.
Re: DefaultCellStyle.NullValue or setting standard error graphic to Bitmap
Think you need to read a bit more carefully .....
To prevent the standard error graphic from appearing for a null reference (Nothing in Visual Basic) or DBNull.Value cell values, set the DataGridViewCellStyle.NullValue property for this cell style object to a null reference (Nothing in Visual Basic) or your own error graphic before adding rows to the control. This does not affect the row for new records, however. To prevent the error graphic from appearing in the row for new records when the control AllowUserToAddRows property value is true, you must also either explicitly set the cell value to a null reference (Nothing in Visual Basic) or your own error graphic in a handler for the control RowsAdded event or set the column CellTemplate property to an instance of a DataGridViewImageCell-derived type with an overridden DefaultNewRowValue property that returns a null reference (Nothing in Visual Basic) or your own error graphic.
If the NullValue property of the object returned by the DefaultCellStyle property has a value equal to the standard error graphic of type Bitmap, changing the ValuesAreIcons property value to true automatically sets NullValue to the standard error graphic of type Icon. If NullValue has a value equal to the standard error graphic of type Icon, changing the ValuesAreIcons property value to false automatically sets NullValue to the standard error graphic of type Bitmap.