The Binding object exposes two events, Format and Parse, both support formatting.data for an application. The Format event occurs whenever data is pushed from the data source to the control, and when it is pulled from the control back to the data source.The Format event is used to translate the data from its native format to the format we
wado.net to display to the use.The Parse event is used to translate it back to its original format and both events receive a ConvertEventArgs argument
- The value property
- The desired property
The Value property contains the actual data. When the event is triggered,the value property will contain the original data in its original format. To change the formatting, you set this value to the new data or format within the event handler. The DesiredType property is used when you are changing the data type of the value.
Using the Format Event
The Format event occurs both when data is being pushed from the data source and when it is pulled from the control, we must be sure we know which action is taking place before performing any action. If we change the data type of the value, we can use the DesiredType property to perform this check.
Using the Parse Event
the Parse event occurs when data is being pulled from a control back to the data source, and it is typically used to “un-format” data that has been customized for display. Because Parse is called only once, this “un-formatting” operation should always happen.