These are two separate problems.
1. TextAfter
I discovered a while back that with TNxNumberEdit if I use text containing a period in the TextAfter property that an error is produced. It's been a while, so I forget exactly the error, but it is probably a conversion problem. For example, "sec" is OK, but 'sec." is not.
2. TNxEdit
I group the responses to the OnChange and OnSelect events of various editors into one procedure. With so many editors in a form I find this helpful. I use the editor's TAG property and (Sender is .. ) to match the editor with what needs to be done.
I'll attach the full code that I am using, but will include a summary here.
Procedure SomethingChanged(Sender:TObject);
var Idx: integer;
var iValue: integer;
var fValue: single;
begin
Idx:=(Sender as TComponent).tag;
// I use Idx, iValue, fValue for my typing/reading convenience.
// I'm using TNxComboBox to get various types of values from the user, including text and the item index.
if (Sender is TNxComboBox) then
begin
iValue:= (Sender as TNxComboBox).ItemIndex;
case IDX of
1: X:= iValue;
2: Y:= (Sender as TNxComboBox).Items[iValue];
end;
end;
// I'm using TNxEdit to get numbers from the user. I needed to be able to use exponential notation for these numbers.
if (Sender is TNxEdit) then
begin
fValue:= StrToFloat(Sender as TNxEdit).AsFloat;
case IDX of
3: S:= fValue;
4: T:= fValue;
end;
end;
// Here of course I am getting only numbers from the user.
if (Sender is TNxComboBox) then
begin
fValue:= (Sender as TNxNmberEdit).AsFloat;
case IDX of
1: A:= fValue;
2: B:= fValue;
end;
end;
end;
The problem here is that whenever the Sender is a TNxComboBox or TNxEditBox the section meant to handle the TNxEdit events is used. For example, after going through the part meant for TNxComboBox, the TNxEdit code is also executed. The same occurs when the Sender is a TNxNumberEdit component. It's as if TNxEdit is also a TNxComboBox and TNxNumberEdit. The way I have written the code here StrToFloat fails when the text is not a number or if it is a number and includes a TextAfter string.
The workaround is easy enough, but figuring this out took me a lot of time. I figured you might like to know about it and fix it.
Mike