I'd done some searches within Experts-Exchange but couldn't find the answer I need. I wonder if someone could help.
I have a TextBox. This TextBox is bound to a BindingSource, which in turn is bound to a data object. I am using two-way bindings.
The member stored in the data object is an integer, eg '412678000'. But it needs to be displayed in decimal up to 3 decimal points. eg. 412.678. (Basically, unit conversion)
Vice versa when user enters the number. He/she enters '412.678' but it shall be stored in the data object as '412678000'.
My data binding code:
tbTxFrequency.DataBindings.Add("Text", bindingSource, "TxFreq", true, DataSourceUpdateMode.OnPropertyChanged, "unknown");
I think I need to add two event handlers (one for Parse, one for Format) to the Data Binding,
tbTxFrequency.DataBindings["Text"].Format += ConvertHzToMHz;
tbTxFrequency.DataBindings["Text"].Parse += ConvertMHzToHz;
But I don't know how to write these event handlers. Could someone please help? Or should it be done by another way?
Thanks in advance.