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.

Syntax

[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ComponentModel.Browsable(false)]
public object DataSourceNullValue { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

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.

Note:

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.

Requirements

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