User Interface / Widgets / Text / Text Box
In This Topic
    Text Box
    In This Topic

    The text box widget can be used to either display or edit text.

     Creating a Text Box

    You create a text by creating an instance of the NTextBox class. The following code snippet creates a text box:

    Creating a Text Box
    Copy Code
    NTextBox textBox = new NTextBox();
    textBox.Text = "Some Text";
    
     Properties
    • Text - specifies the text displayed by the text box

    • Hint - specifies text that is displayed by the text box when the text box Text property does not contain characters. You can use this property to prompt the user that he or she must input some specific text inside the text box. The following code example shows how to use this property:

      Using the Hint Property
      Copy Code
      NTextBox textBox = new NTextBox();
      textBox.Hint = "Type Address Here";
      
    • HintFill - specifies the filling used for the Hint text.

    • TextAlign - specifies how each line of text is aligned relative to the text box content area. The following table lists the available options:

      ENTextHorzAlign Description
      Left Each text line is left aligned to the content area
      Center Each text line is center aligned to the content area
      Right Each text line is right aligned to the content area
    • TextAlignment - specifies how text is aligned relative to the text box bounding box. This property accepts values from the ENContentAlignment enum.

    • Multiline - specifies whether the text should display multi line text

    • WordWrap - specifies whether lines are automatically word wrapped when multiline is enabled

    • AcceptsTab - specifies whether tab characters are accepted as input.

    • AcceptsEnter - specifies whether return characters are accepted as input.

    • ReadOnly - specifies whether text is read only. In read only mode user is not allowed to alter the text.

    • PasswordChar - specifies a password char. When the password char is set to any value different than 0 the control will enter in password mode and display that character repeatedly to match the length of the text input by the user. Clipboard copy is disabled when the control is in password mode.

    • MaxLength - the maximum length of the text accepted by this text box. By default set to Int32.MaxValue.

    • CharacterCasing - specifies the current character casing. The following table lists the available options:

      ENCharacterCasing Description
      Normal Characters retain their original casing.
      UpperCase All characters are converted to upper case.
      LowerCase All characters are converted to lower case.
    • VScrollMode and HScrollMode - those two properties control when the horizontal and vertical scrollbars area visible. The following table lists the available options:

      ENScrollMode Description
      Never The scrollbar are is never visible.
      Always The scrolling is always visible and enabled only when needed.
      WhenNeeded The scrollbar is visible and enabled only when needed (when text content size exceeds the bounds of the text box).

      The following code snippet shows how to create a multiline, scrollable text box:

      Creating a Multiline, Scrollable Textbox
      Copy Code
      NTextBox textBox = new NTextBox();
      textBox.VScrollMode = ENScrollMode.Always;
      textBox.HScrollMode = ENScrollMode.Always;
      textBox.Multiline = true;
      textBox.AcceptsEnter = true;
      

     

    See Also