Skip to content

DateTimePicker

Summary

Represents the date time picker control.

Signature

1
public class DateTimePicker : ControlBase

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 using cAlgo.API;
 namespace cAlgo.Robots;
 [Robot(AccessRights = AccessRights.None)]
 public class TestExample : Robot
 {
    protected override void OnStart()
    {
        var dateTimePicker = new DateTimePicker 
        {
             Value = Server.Time,
             MaxValue = Server.Time.AddMonths(1),
             MinValue = Server.Time.AddMonths(-1)
        };
        dateTimePicker.ValueChanged += args => Print($"Date Time Picker value change to: {args.NewValue}");
        var changeValueButton = new Button {Text = "Change Value"};
        changeValueButton.Click += args => dateTimePicker.Value = Server.Time.AddDays(1);
        var panel = new StackPanel 
        {
             Orientation = Orientation.Vertical,
             HorizontalAlignment = HorizontalAlignment.Center,
             VerticalAlignment = VerticalAlignment.Center
        };
        panel.AddChild(dateTimePicker);
        panel.AddChild(changeValueButton);
        Chart.AddControl(panel);
    }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 import clr
 clr.AddReference("cAlgo.API")
 # Import cAlgo API types
 from cAlgo.API import *
 # Import trading wrapper functions
 from robot_wrapper import *
 class Test():
     def on_start(self):
         self.dateTimePicker = DateTimePicker()
         self.dateTimePicker.Value = api.Server.Time
         self.dateTimePicker.MaxValue = api.Server.Time.AddMonths(1)
         self.dateTimePicker.MinValue = api.Server.Time.AddMonths(-1)
         self.dateTimePicker.ValueChanged += lambda args: print(f"Date Time Picker value change to: {args.NewValue}")
         changeValueButton = Button()
         changeValueButton.Text = "Change Value"
         changeValueButton.Click += self.on_change_value_button_clicked
         panel = StackPanel()
         panel.Orientation = Orientation.Vertical
         panel.HorizontalAlignment = HorizontalAlignment.Center
         panel.VerticalAlignment = VerticalAlignment.Center
         panel.AddChild(self.dateTimePicker)
         panel.AddChild(changeValueButton)
         api.Chart.AddControl(panel)
     def on_change_value_button_clicked(self, args):
         self.dateTimePicker.Value = api.Server.Time.AddDays(1)

Methods

ChangeValue

Signature

1
private void ChangeValue(DateTime newValue)

Parameters

Name Type Description
newValue DateTime

Return Value

void

Properties

Value

Summary

Gets or sets value.

Signature

1
public DateTime Value {get; set;}

Return Value

DateTime

MaxValue

Summary

Gets or sets maximum value.

Signature

1
public DateTime MaxValue {get; set;}

Return Value

DateTime

MinValue

Summary

Gets or sets minimum value.

Signature

1
public DateTime MinValue {get; set;}

Return Value

DateTime

ShowTimeInput

Summary

Gets or sets whether show time picker input or not.

Signature

1
public bool ShowTimeInput {get; set;}

Return Value

bool

Events

ValueChanged

Summary

Occurs when value is changed.

Signature

1
public event Action<DateTimePickerValueChangedEventArgs> ValueChanged;