The TSpinEdit control is found on the the miscellaneous tab of the Component Palette. It is useful for setting a numeric setting made on a form. TSpinEdit is in fact a combination of a TUpDown and an associated TEdit control specialized for numbers.
Most relevant properties of a TSpinEdit are:
- MinValue: lowest value allowed
- MaxValue: highestest value allowed
- Increment: the increment/decrement if one of the buttons is clicked
The background color, font color, type style, and other similar matters are available to the user. To change the background color, go to the Object Inspector, then select the drop down list which shows the available colors.
The listing provides a comprehensive list of colors, but a user can also choose a color by clicking the button to the right of the property -- Color beyond the drop down list. Upon clicking a dialog box opens which enables to user to create their own color.
In a similar manner the font color, type style and other similar properties can be selected.
It is also possible to change these properties using pascal code. In this case a form is created and a TSpinEdit control is selected and dropped onto the form. The OnClick event is selected from Events in the Object Inspector with the button on the right side being clicked. This creates the code block to which the background color property is changed:
procedure TForm1.SpinEdit1Click(Sender : TObject) ; begin SpinEdit1.Color := clLime; end;
After click the Key-F9 or select Run from the Run Menu. The form after compiling with appear. After clicking inside the TSpinEdit control the color will change:
Most other properties can be changed in a similar manner.
By default the numeric range of the TSpinEdit control is MinValue = 0 and MaxValue = 100. A custom range can be established by changing this values. Again, it is also possible to change them in the pascal code blocks. The incremental value by default is 1, but this can be set to another number. The default shown value is 0, but again this may be changed in the Object Inspector to another value or it can be set from the program.
The alignment can be changed from the default of taLeftJustify, to taCenterJustify or taRightJustify.