テキストボックスの操作
Aspose.Words では、TextBox クラスを使用して、図形内にテキストを表示する方法を指定します。 Parent という名前のパブリック プロパティを公開してテキスト ボックスの親図形を取得し、顧客が関連付けられた TextBox からリンクされた Shape を見つけられるようにします。
リンクの作成
TextBox クラスは、TextBox がターゲット Textbox にリンクできるかどうかを確認するための IsValidLinkTarget メソッドを提供します。
次のコード例は、TextBox
がターゲットのテキストボックスにリンクできるかどうかを確認する方法を示しています。
// 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; |
テキストボックスのシーケンスを確認する
図形内にテキストを表示するには、いくつかの方法があります。 TextBox は、シーケンスの先頭、中間、または末尾のいずれかになります。
次のコード例は、TextBox がシーケンスの先頭、末尾、または中間であるかどうかを確認する方法を示しています。
// 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."); | |
} |
リンクを解除する
BreakForwardLink メソッドを使用すると、次の TextBox へのリンクを切断できます。
次のコード例は、TextBox のリンクを解除する方法を示しています。
// 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(); |