TMSFNCDigitalTimeSelector / TMSFNCDigitalTimePicker
The TMSFNCDigitalTimeSelector and TMSFNCDigitalTimePicker are components that display a grid of selectable time values. The header is used for navigating between the pages of these values. In both components the OnTimeSelected/OnTimeDeselected event gets triggered when a time gets selected/deselected.
If you would like to change the amount of selectable times that is being displayed on one page, you can use the Rows and Columns properties to set the number of rows and columns.
In the TMSFNCDigitalTimeSelector there are a few methods and properties that can be accessed programmatically. Only the currently displayed times are stored in a collection, so if you need to jump to a specific time, you can use the InitializePage(ATime: TTime) method, which will clear out the currently stored times and set the new ones based on the start time, time interval, interval unit and of course, the ATime parameter.
procedure TForm1.FormCreate(Sender: TObject); begin TMSFNCAnalogTimeSelector1.Settings.Auto := True; TMSFNCDigitalTimeSelector1.InitializePage(Now); end;
To navigate between the pages, you can use the NavigateBack and NavigateForth methods.
To access the currently stored/displayed times, use the Items property. Setting and accessing the selected time can be done via the SelectedTime property, as you can see in the example code shown below:
procedure TForm1.FormCreate(Sender: TObject); begin TMSFNCDigitalTimeSelector1.InitializePage(Now); TMSFNCDigitalTimeSelector1.SelectedTime := StrToTime('12:30:00'); end;
In both components you can use the StartTime and EndTime properties to set the selectable time range. By defult, there’s a 5 minute interval between each time item, but this can be easily reconfigured with the TimeInterval and IntervalUnit properties. You can set the IntervalUnit to tsuMilliseconds, tsuSeconds, tsuMinutes and tsuHours. The TimeInterval property requires an Integer value. The default time format is hh:nn:ss, but it can be changed via the TimeFormat property.
procedure TForm1.FormCreate(Sender: TObject); begin TMSFNCDigitalTimeSelector1.StartTime := StrToTime('08:00:00'); TMSFNCDigitalTimeSelector1.EndTime := StrToTime('16:30:00'); TMSFNCDigitalTimeSelector1.TimeInterval := 30; TMSFNCDigitalTimeSelector1.TimeFormat := 'hh:nn'; end;
The TMSFNCDigitalTimePicker has an Editable property. With the Editable enabled, you can write the time you’d like to select, and clicking the dropdown will automatically set the grid to the time that’s written into the field.