System.Windows.Forms.DataGridViewCellStyle.DataSourceNullValue Property

Gets or sets the value saved to the data source when the user enters a null value into a cell.


public object DataSourceNullValue { set; get; }


Documentation for this section has not yet been entered.


The user can enter a null value into a cell by pressing CTRL+0 or by typing the value of the DataGridViewCellStyle.NullValue property. When the user commits the change, the underlying cell value is set to the value of the DataGridViewCellStyle.DataSourceNullValue property or to null if DataGridViewCellStyle.DataSourceNullValue is DBNull.Value and the cell DataGridViewCell.ValueType is a reference type. This conversion does not occur when you set the DataGridViewCell.Value property programmatically.


The control does not display the DataGridViewCellStyle.NullValue property value for cell values equal to the DataGridViewCellStyle.DataSourceNullValue property value when DataGridViewCellStyle.DataSourceNullValue is set to a value other than DBNull.Value or null. In this case, you can handle the DataGridView.CellFormatting event to display the DataGridViewCellStyle.NullValue property value. For more information, see the code example in this topic.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions:
Since: .NET 2.0