TSpinEdit

From Lazarus wiki
Revision as of 20:54, 15 July 2016 by Abtaylr (talk | contribs)
Jump to navigationJump to search

The TSpinEdit control is found in the miscellaneous visual components of the LCL Component tree. It is useful for setting a numeric setting made on a form. It can be selected from the component palette found commonly across the top of the main Lazarus IDE just below the main menu. As an alternative this palette can be placed by the user in a different location. The component is also available for manual entry in a program.

TSpinEdit01.png


Visual Properties

Numerous properties are available. 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.

TSpinEdit02.png

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.

TSpinEdit03.png

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:

    TSpinEdit04.png     TSpinEdit05.png

Most other properties can be changed in a similar manner.


Other Properties

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.