dotnetmonitor.com

 
Index
Previous
Next

 

The DataGridViewCellStyle.NullValue property should have been called FormattedNullValue, but it was too late to make this change. Hopefully this provides a clue into how the NullValue is used at formatting time. When a cells value is null (equal to Null or DBNull.Value) the value in the DataGridViewCellStyle.NullValue property is used for display. The default value of this property is based upon the column:

DataGridView column

Columns DefaultCellStyle.NullValue

TextBoxColumn

String.Empty ()

ImageColumn

Null image ()

ComboBoxColumn

String.Empty ()

ButtonColumn

String.Empty ()

LinkColumn

String.Empty ()

CheckBoxColumn

Default is based upon the ThreeState property. If true default value is CheckState.Indeterminate; otherwise it is false (unchecked).

What is important to understand is that the NullValue is also used when the user enters data. For example, if the user enters String.Empty into a text box cell then Null is entered as the cells value (check out the DataSourceNullValue below for more details on what is actually entered as the cells value).

What is the DataGridView
Differences between the DataGridView and DataGrid controls
Highlight of features
Structure of DGV
Architecture Elements
Cells and Bands