User Tools

Site Tools


16.6.0 TextBoxes

Subjects of the considerations in chapters 16.6 to 16.11 are the component TextBox and its specializations MaskBox, ValueBox, HistoryBox, InputBox and ButtonBox. TextBox

The class TextBox (gb.qt4) implements a one-line text input component.


Figure TextBoxes for entering ①, ② and displaying ③ strings

First, selected properties and methods of the TextBox class are described and then essential events are characterized. Finally, in → chapter 16.6.3 examples for the use of a TextBox in different applications are presented. Property TextBox

The class TextBox has these essential properties:

PropertyData typeDescription
AlignmentIntegerSets or returns the text alignment in the TextBox. You can use one of the following constants: Align.Normal, Align.Left, Align.Center or Align.Right.
FontFontSets the font or returns the font.
ForegroundIntegerSets the writing color or returns the color value.
LengthIntegerReturns the text length of the text in the TextBox.
MaxLengthIntegerSets or returns the maximum text length in the TextBox.
PasswordBooleanFor the value True, asterisks are set instead of the individual characters.
PosIntegerSets the cursor position (number of characters from the beginning of the text) or returns the cursor position.
ReadOnlyBooleanIndicates with TRUE that the text cannot be changed (display mode).
SelectedBooleanReturns TRUE if text is selected in the TextBox.
SelectionTextBox. SelectionReturns an object of type TextBox.Selection with which the selected text can be edited.
TextStringSets the text in the TextBox or returns the text as a string.

Table Properties of the TextBox class Methods TextBox

Only essential methods are presented for the TextBox class:

Clear()Deletes all text in the TextBox.
Insert(text* As String)Inserts the specified text* at the current cursor position into the text.
Select([ Start As Integer, Length As Integer])Defines the text to be marked. Start is the position of the first selected character in the text. Length is the length of the marker. If no argument is specified, the entire text is selected and highlighted.
SelectAll()Selects the entire text.
Unselect()Cancels the selection of selected text.

Table Methods of the TextBox class Events TextBox

These events are specific to a TextBox:

Activate ()The event is triggered when the Enter key is pressed while the TextBox has the focus.
Change ()The event is triggered when the text in the TextBox changes. This happens when characters are entered using the keyboard or when the value of the TextBox.Text property changes.
KeyPress ()Is triggered when a key is pressed while the TextBox is in focus. You receive information about the pressed key with the key class.

Table Selected events of the TextBox class




The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k16/k16.6/start.txt · Last modified: 29.09.2023 by emma

Page Tools