System.Windows.Forms.DataGridViewCellParsingEventHandler Delegate

Represents the method that will handle a DataGridView.CellParsing event of a System.Windows.Forms.DataGridView.

Syntax

public delegate void DataGridViewCellParsingEventHandler (object sender, DataGridViewCellParsingEventArgs e)

Parameters

sender
Documentation for this section has not yet been entered.
e
Documentation for this section has not yet been entered.

Remarks

Handle the DataGridView.CellParsing event to provide custom value conversion from a user-specified value to a value in the type specified by the cell DataGridViewCell.ValueType property.

When you handle the DataGridView.CellParsing event, you can convert the value yourself or you can customize the default conversion. For example, you can convert the value yourself using the cell DataGridViewCell.ParseFormattedValue(object, DataGridViewCellStyle, System.ComponentModel.TypeConverter, System.ComponentModel.TypeConverter) method with type converters of your choosing. Alternatively, you can let the default type converters parse the value, but modify the DataGridViewCellStyle.NullValue, DataGridViewCellStyle.DataSourceNullValue, and DataGridViewCellStyle.FormatProvider properties of the object returned by the DataGridViewCellParsingEventArgs.InheritedCellStyle property, which is initialized using the cell DataGridViewCell.InheritedStyle property.

When you convert the value yourself, replace the initial, formatted value of the ConvertEventArgs.Value property with the converted value in the type specified by the cell DataGridViewCell.ValueType property. To indicate that no further parsing is necessary, set the DataGridViewCellParsingEventArgs.ParsingApplied property to true.

When the event handler completes, if the ConvertEventArgs.Value is null or is not of the correct type, or the DataGridViewCellParsingEventArgs.ParsingApplied property is false, the ConvertEventArgs.Value is parsed using the cell DataGridViewCell.ParseFormattedValue(object, DataGridViewCellStyle, System.ComponentModel.TypeConverter, System.ComponentModel.TypeConverter) method with default type converters. The default implementation of this method parses the value using the DataGridViewCellStyle.NullValue, DataGridViewCellStyle.DataSourceNullValue, and DataGridViewCellStyle.FormatProvider properties of the cell style passed in. If the value is not equal to DataGridViewCellStyle.NullValue, the value is parsed using the DataGridViewCellStyle.FormatProvider property and the type converters passed in.

To customize the conversion of a cell value into a formatted value for display, handle the DataGridView.CellFormatting event.

For more information about handling events, see Consuming Events.

When you create a System.Windows.Forms.DataGridViewCellParsingEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see Events and Delegates.

Requirements

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