Arbeiten mit TextBoxen
In Aspose.Words wird die TextBox-Klasse verwendet, um anzugeben, wie Text innerhalb einer Form angezeigt wird. Es stellt eine öffentliche Eigenschaft namens Parent bereit, um die übergeordnete Form für das Textfeld abzurufen, sodass der Kunde das verknüpfte Shape im zugehörigen TextBox finden kann.
Einen Link erstellen
Die TextBox-Klasse stellt die IsValidLinkTarget-Methode bereit, um zu prüfen, ob das TextBox mit dem Ziel-Textbox verknüpft werden kann.
Das folgende Codebeispiel zeigt, wie überprüft wird, ob das TextBox
mit der Zieltextbox verknüpft werden kann:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(); | |
Shape shape1 = new Shape(doc, ShapeType.TextBox); | |
Shape shape2 = new Shape(doc, ShapeType.TextBox); | |
TextBox textBox1 = shape1.TextBox; | |
TextBox textBox2 = shape2.TextBox; | |
if (textBox1.IsValidLinkTarget(textBox2)) | |
textBox1.Next = textBox2; |
Überprüfen Sie die TextBox-Sequenz
Es gibt verschiedene Möglichkeiten, Text in einer Form anzuzeigen. Der TextBox kann der Kopf, die Mitte oder das Ende einer Sequenz sein.
Das folgende Codebeispiel zeigt, wie überprüft wird, ob TextBox ein Head, Tail oder Middle der Sequenz ist:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(); | |
Shape shape = new Shape(doc, ShapeType.TextBox); | |
TextBox textBox = shape.TextBox; | |
if ((textBox.Next != null) && (textBox.Previous == null)) | |
{ | |
Console.WriteLine("The head of the sequence"); | |
} | |
if ((textBox.Next != null) && (textBox.Previous != null)) | |
{ | |
Console.WriteLine("The Middle of the sequence."); | |
} | |
if ((textBox.Next == null) && (textBox.Previous != null)) | |
{ | |
Console.WriteLine("The Tail of the sequence."); | |
} |
Einen Link brechen
Mit der BreakForwardLink-Methode können Sie die Verknüpfung zum nächsten TextBox unterbrechen.
Das folgende Codebeispiel zeigt, wie man einen Link für ein TextBox unterbricht:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(); | |
Shape shape = new Shape(doc, ShapeType.TextBox); | |
TextBox textBox = shape.TextBox; | |
// Break a forward link | |
textBox.BreakForwardLink(); | |
// Break a forward link by setting a null | |
textBox.Next = null; | |
// Break a link, which leads to this textbox | |
if (textBox.Previous != null) | |
textBox.Previous.BreakForwardLink(); |