Bekerja dengan Kotak Teks
Di Aspose.Words, kelas TextBox digunakan untuk menentukan bagaimana teks ditampilkan di dalam suatu bentuk. Ini memperlihatkan properti publik bernama Parent untuk mendapatkan bentuk induk untuk kotak teks sehingga pelanggan dapat menemukan Shape tertaut dari TextBox terkait.
Membuat Tautan
Kelas TextBox menyediakan metode IsValidLinkTarget untuk memeriksa apakah TextBox dapat ditautkan ke Textbox target.
Contoh kode berikut menunjukkan cara memeriksa apakah TextBox
dapat ditautkan ke Kotak Teks target:
// 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; |
Periksa Urutan Kotak Teks
Ada beberapa cara untuk menampilkan teks dalam bentuk. TextBox bisa menjadi Kepala, Tengah, atau Ekor dari suatu urutan.
Contoh kode berikut menunjukkan cara memeriksa apakah TextBox adalah Kepala, Ekor, atau Tengah dari urutan:
// 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."); | |
} |
Memutus Tautan
Dengan menggunakan metode BreakForwardLink Anda dapat memutus tautan ke TextBox berikutnya.
Contoh kode berikut menunjukkan cara memutus tautan untuk 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(); |