I'm trying to write an exception handler that displays user friendly messages. I don't know how to get the "Newly Entered" data value that caused the TDBGridInplaceEdit error.
For example:
I have a DBGrid loaded with data. When I intentionally change the PartNo field of row #1 to a non numeric value to cause a TDBGridInplaceEdit error... (From: 1313.3 To: 1313..3) ... I trap the error and display a message but I can't figure out how to get the bad '1313..3' value.
Original PartNo: 1313.3
Changed PartNo: 1313..3 (two decimal points)
Displayed Error Message from the Application onException
procedure TMain.ApplicationEvents1Exception(Sender: TObject; E: Exception);
var
str : string;
begin
str := sender.ToString;
str := str + #10;
str := str + RzDBGrid2.SelectedField.FieldName;
str := str + #10;
str := str + VarToStr(RzDBGrid2.SelectedField.Value);
str := str + #10;
str := str + e.Message;
showmessage(str);
//Application.ShowException(E);
end;
I'd like to format my own message using the bad '1313..3' value that was entered. How do you get this value?
If you are persisting the fields of your dataset, you can define an OnSetText Method on your fields.(Doubleclick on the dataset and choose add fields).
The Method could look like this:
If you want to avoid persisting your fields you can dynamically assign the Method to the field, e.g. after opening the Dataset.