GrapeCity.Win.MultiRow Namespace > GcMultiRow Class : CellParsing Event |
<FeatureAttribute(Name="DataTranslation", Version="v5.0")> <SRDescriptionAttribute("Occurs when a cell leaves edit mode if the cell value has been modified. ")> <SRCategoryAttribute("Display")> Public Event CellParsing As EventHandler(Of CellParsingEventArgs)
Dim instance As GcMultiRow Dim handler As EventHandler(Of CellParsingEventArgs) AddHandler instance.CellParsing, handler
[Feature(Name="DataTranslation", Version="v5.0")] [SRDescription("Occurs when a cell leaves edit mode if the cell value has been modified. ")] [SRCategory("Display")] public event EventHandler<CellParsingEventArgs> CellParsing
The event handler receives an argument of type CellParsingEventArgs containing data related to this event. The following CellParsingEventArgs properties provide information specific to this event.
Property | Description |
---|---|
CellIndex | Gets the cell index in its parent Section. |
CellName | Gets the cell name. |
CellStyle | Gets or sets the style applied to the edited cell. |
DesiredType | (Inherited from System.Windows.Forms.ConvertEventArgs) |
ParsingApplied | Gets or sets a value that indicates whether a cell's value has been successfully parsed. |
RowIndex | Gets the index of the owner Row that the event occurs for. |
Scope | Gets the cell area that the event occurs for. |
SectionIndex | Gets the index of the owner Section that the event occurs for. |
Value | (Inherited from System.Windows.Forms.ConvertEventArgs) |
By default, the GcMultiRow control attempts to convert a user specified value displayed in a cell to an actual underlying cell value of the type specified by the cell ValueType property. This conversion uses the formatting properties of the cell style returned by the cell InheritedStyle property.
If the standard conversion is not adequate, handle the CellParsing event to provide custom value conversion to the required type.
Users can enter edit mode using the method specified by the EditMode property. They can leave edit mode, and commit any changes to a cell, by moving to another cell or by pressing Enter. Pressing Esc will revert any changes to the value before it was committed, and the CellParsing event will not occur. The CellParsing event occurs only if the cell value has actually been modified, even if the final value is the same as the original value. It also occurs when the CommitEdit method is called.
When you handle the CellParsing event, you can convert the value yourself or you can customize the default conversion.You can let the default type converters parse the value, but modify the NullValue, DataSourceNullValue, and FormatProvider properties of the object returned by the CellParsingEventArgs.CellStyle property. The cell style is initialized using the cell InheritedStyle property.
When you convert the value yourself, replace the initial, formatted value of the System.Windows.Forms.ConvertEventArgs.Value property with the converted value of the type specified by the cell ValueType property. To indicate that no further parsing is necessary, set the ParsingApplied property to true.
When the event handler completes, if the System.Windows.Forms.ConvertEventArgs.Value is a null reference (Nothing in Visual Basic) or is not of the correct type, or the ParsingApplied property is false, the value is parsed using default type converters. The default implementation of this method parses the value using the NullValue, DataSourceNullValue, and FormatProvider properties of the cell style passed in. If the value is not equal to NullValue, the value is parsed using the FormatProvider property and the type converters passed in.
To customize the conversion of a cell value into a formatted value for display, handle the CellFormatting event.
The event order when a user edits a cell's value and then clicks to another cell to apply the cell's value is as follows:
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2