User Tools

Site Tools


k16:k16.6:start

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.

16.6.0.1 TextBox

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

B1

Figure 16.6.0.1.1: 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.

16.6.0.2 Property TextBox

The class TextBox has these essential properties:

tablelayout

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 16.6.0.2.1: Properties of the TextBox class

16.6.0.3 Methods TextBox

Only essential methods are presented for the TextBox class:

tablelayout

MethodDescription
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 16.6.0.3.1: Methods of the TextBox class

16.6.0.4 Events TextBox

These events are specific to a TextBox:

tablelayout

EventDescription
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 16.6.0.4.1: Selected events of the TextBox class

Download

Articles

Download


16.6.0 TextBoxen

Gegenstand der Betrachtungen in den Kapiteln 16.6 bis 16.11 sind die Komponente TextBox und ihre Spezialisierungen MaskBox, ValueBox, HistoryBox, InputBox und ButtonBox.

16.6.0.1 TextBox

Die Klasse TextBox (gb.qt4) implementiert eine einzeilige Texteingabe-Komponente.

B1

Abbildung 16.6.0.1.1: TextBoxen zur Eingabe ①, ② und zur Anzeige ③ von Strings

Zuerst werden ausgewählte Eigenschaften und Methoden der Klasse TextBox beschrieben und dann wesentliche Ereignisse charakterisiert. Abschließend werden im → Kapitel 16.6.3 Beispiele für den Einsatz einer TextBox in unterschiedlichen Anwendungsfällen vorgestellt.

16.6.0.2 Eigenschaften TextBox

Die Klasse TextBox besitzt diese wesentlichen Eigenschaften:

EigenschaftDatentypBeschreibung
AlignmentIntegerSetzt die Text-Ausrichtung in der TextBox oder gibt diese Ausrichtung zurück. Sie können eine der folgenden Konstanten einsetzen: Align.Normal , Align.Left , Align.Center oder Align.Right.
FontFontSetzt den Font oder gibt den Font zurück.
ForegroundIntegerSetzt die Schreib-Farbe oder gibt den Farbwert zurück.
LengthIntegerGibt die Textlänge des Textes in der TextBox zurück.
MaxLengthIntegerSetzt die maximale Textlänge in der TextBox oder gibt diesen Wert zurück.
PasswordBooleanFür den Wert True werden Sternchen an Stelle der einzelnen Zeichen gesetzt.
PosIntegerSetzt die Cursor-Position (Zeichenzahl vom Beginn des Textes) oder gibt die Cursor-Position zurück.
ReadOnlyBooleanZeigt mit TRUE an, das der Text nicht geändert werden kann (Anzeige-Modus).
SelectedBooleanGibt TRUE zurück, sofern Text in der TextBox markiert ist.
SelectionTextBox.SelectionGibt ein Objekt vom Typ TextBox.Selection zurück, mit dem der selektierte Text bearbeitet werden kann.
TextStringSetzt den Text in der TextBox oder gibt den Text als Zeichenkette zurück.

Tabelle 16.6.0.2.1 : Eigenschaften der Klasse TextBox

16.6.0.3 Methoden TextBox

Für die Klasse TextBox werden nur wesentliche Methoden vorgestellt:

1x1MethodeBeschreibung
Clear ( )Löscht den gesamten Text in der TextBox.
Insert ( Text* As String )Fügt den angegebenen Text* an der aktuellen Cursorposition in den Text ein.
Select ( [ Start As Integer, Length As Integer ] )Definiert den zu markierenden Text. Start ist die Position des ersten ausgewählten Zeichens im Text. Length ist die Länge der Markierung. Wenn kein Argument angegeben ist, so wird der gesamte Text ausgewählt und markiert.
SelectAll ( )Markiert den gesamten Text.
Unselect ( )Nimmt die Markierung von selektiertem Text zurück.

Tabelle 16.6.0.3.1 : Methoden der Klasse TextBox

16.6.0.4 Ereignisse TextBox

Diese Ereignisse sind spezifisch für eine TextBox:

1x1EreignisBeschreibung
Activate ( )Das Ereignis wird ausgelöst, wenn die Eingabe-Taste gedrückt wird, während die TextBox den Fokus hat.
Change ( )Das Ereignis wird ausgelöst, wenn sich der Text in der TextBox ändert. Das passiert, wenn Zeichen über die Tastatur eingegeben werden oder wenn sich der Wert der Eigenschaft TextBox.Text ändert.
KeyPress ( )Wird ausgelöst, wenn eine Taste gedrückt wird, während die TextBox den Fokus hat. Sie erhalten Informationen über die gedrückte Taste mit der Key-Klasse.

Tabelle 16.6.0.4.1 : Ausgewählte Ereignisse der Klasse TextBox

Download

Artikel

Download

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: 02.07.2018 (external edit)

Page Tools