Skip to content

TextChangedEventArgs.TextBox

property · TextChangedEventArgs · cAlgo.API

DesktopCLICloud

Gets the texbox.

Environment behaviour

CLI — not supported. Never raised in the CLI: the events that pass it never fire there (TextBox.TextChanged).

Cloud — not supported. Never raised in the cloud: the events that pass it never fire there (TextBox.TextChanged).

Definition

public TextBox TextBox {get;}
textChangedEventArgs.TextBox: TextBox

Returns TextBox

Examples

protected override void OnStart()
{
    var volumeTextBox = new TextBox { Text = "10000", Width = 100 };
    volumeTextBox.TextChanged += OnVolumeTextChanged;
    Chart.AddControl(volumeTextBox);
}

private void OnVolumeTextChanged(TextChangedEventArgs args)
{
    var isValid = double.TryParse(args.TextBox.Text, out var volume) && volume > 0;
    args.TextBox.ForegroundColor = isValid ? Color.White : Color.Red;
}
def on_start(self):
    volumeTextBox = TextBox()
    volumeTextBox.Text = "10000"
    volumeTextBox.Width = 100
    volumeTextBox.TextChanged += self.on_volume_text_changed
    api.Chart.AddControl(volumeTextBox)

def on_volume_text_changed(self, args):
    try:
        isValid = float(args.TextBox.Text) > 0
    except ValueError:
        isValid = False
    args.TextBox.ForegroundColor = Color.White if isValid else Color.Red