Skip to content

TextBox

class cAlgo.API

DesktopCLICloud

Represents the text box class.

Environment behaviour

CLI — not supported. Accepted without error but never displayed, so control events such as Click are never raised.

Cloud — not supported. Accepted without error but never displayed, so control events such as Click are never raised.

Definition

public class TextBox : Control

Namespace: cAlgo.API · Group: Controls · Inherits: Control, ControlBase

Examples

using cAlgo.API;

namespace cAlgo
{
    // This sample indicator shows how to add a text box control on your chart
    public partial class TextBoxSample : Indicator
    {
        protected override void Initialize()
        {
            var stackPanel = new StackPanel
            {
                BackgroundColor = Color.Gold,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Opacity = 0.6,
            };

            var textBox = new TextBox
            {
                Text = "Enter text here...",
                FontWeight = FontWeight.ExtraBold,
                Margin = 5,
                ForegroundColor = Color.White,
                HorizontalAlignment = HorizontalAlignment.Center,
                Width = 150
            };

            textBox.TextChanged += TextBox_TextChanged;

            stackPanel.AddChild(textBox);

            Chart.AddControl(stackPanel);
        }

        private void TextBox_TextChanged(TextChangedEventArgs obj)
        {
            Print("Text box text changed to: ", obj.TextBox.Text);
        }

        public override void Calculate(int index)
        {
        }
    }
}
import clr
clr.AddReference("cAlgo.API")

from cAlgo.API import *

class Test():
    def initialize(self):
        stackPanel = StackPanel()
        stackPanel.BackgroundColor = Color.Gold
        stackPanel.HorizontalAlignment = HorizontalAlignment.Center
        stackPanel.VerticalAlignment = VerticalAlignment.Center
        stackPanel.Opacity = 0.6

        textBox = TextBox()
        textBox.Text = "Enter text here..."
        textBox.FontWeight = FontWeight.ExtraBold
        textBox.Margin = Thickness(5)
        textBox.ForegroundColor = Color.White
        textBox.HorizontalAlignment = HorizontalAlignment.Center
        textBox.Width = 150

        textBox.TextChanged += lambda args: api.Print(f"Text box text changed to: {args.TextBox.Text}")

        stackPanel.AddChild(textBox)

        api.Chart.AddControl(stackPanel)
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true
}

Constructors

Name Description
TextBoxDesktopCLICloud Initializes a new instance of the TextBox class.

Properties

Name Description
AcceptsReturnDesktopCLICloudbool Gets or sets a value that indicates how the text editing control responds when the user presses the ENTER key.
AcceptsTabDesktopCLICloudbool Gets or sets a value that indicates how the text editing control responds when the user presses the TAB key.
BorderColorDesktopCLICloudColor Gets or sets the color of the text box border.
BorderThicknessDesktopCLICloudThickness Gets or sets the border thickness. Property value can be set using Thickness, number, or a string new Thickness(5), new Thickness(1, 2, 3, 4), 5, "5", "1 2 3 4".
CaretColorDesktopCLICloudColor Gets or sets the color of the insertion caret.
CharacterCasingDesktopCLICloudCharacterCasing Gets or sets whether the TextBox control modifies the case of characters as they are typed.
HorizontalScrollBarVisibilityDesktopCLICloudScrollBarVisibility Defines the horizontal scroll bar visibility.
IsReadOnlyDesktopCLICloudbool Gets or sets a value indicating whether the current text box is read-only.
IsReadOnlyCaretVisibleDesktopCLICloudbool Gets or sets a value that indicates whether a read-only text box displays a caret.
MaxLengthDesktopCLICloudint Gets or sets the maximum number of characters that can be manually entered into the text box.
MaxLinesDesktopCLICloudint Gets or sets the maximum number of visible lines.
MinLinesDesktopCLICloudint Gets or sets the minimum number of visible lines.
SelectionColorDesktopCLICloudColor Gets or sets the text color of the current text selection.
SelectionOpacityDesktopCLIClouddouble Gets or sets the opacity of the selected text.
TextDesktopCLICloudstring Gets or sets the text.
TextAlignmentDesktopCLICloudTextAlignment Gets or sets a value that indicates the horizontal alignment of text content.
TextWrappingDesktopCLICloudTextWrapping Gets or sets how the text box should wrap text.
VerticalScrollBarVisibilityDesktopCLICloudScrollBarVisibility Defines the vertical scroll bar visibility.

Events

Name Description
TextChangedDesktopCLICloudAction<TextChangedEventArgs> Occurs when the text has changed.

Inherited members

From Control: ForegroundColor, BackgroundColor, Padding, VerticalContentAlignment, HorizontalContentAlignment, FontWeight, FontStyle, FontFamily, FontSize

From ControlBase: ResetProperty, UniqueId, Style, Left, Top, Right, Bottom, Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight, IsEnabled, IsVisible, Opacity, Margin, VerticalAlignment, HorizontalAlignment, Dock, IsHitTestVisible