This seems to have been done by design, but I cannot see a valid reason for this and it could be a little dangerous when being used to control the valid values entered.
By putting the following in the OnChange event I've managed to get around the problem. Not sure if there is a better solution.
if (Sender is TSpinEdit) then
begin
if (Sender as TSpinEdit).Value > (Sender as TSpinEdit).MaxValue then
begin
(Sender as TSpinEdit).Value := (Sender as TSpinEdit).MaxValue;
end;
end;
with (Sender as TSpinEdit) do Value := Min(Value, MaxValue);
ReplyDeleteNo need to check if it's a TSpinEdit unless you assign the handler to something that is not a TSpinEdit...
I never use 'with' statements, they are a very very bad idea and have seen issues so many times when people have used them.
ReplyDeleteAFAIK, MaxValue is the maximum value for the spinner (the TUpDown part), not for the edit.
ReplyDeleteYes, the MaxValue is just for the spinner button not for the whole component (TCustomEdit with a TSpinButton). This is not clearly obvious at design time naming the property to SpinButtonMaxValue would help. I believe this could have been designed better.
Delete