การทำงานกับกล่องข้อความ
ใน Aspose.Words คลาส TextBox ใช้เพื่อระบุวิธีแสดงข้อความภายในรูปร่าง โดยเปิดเผยทรัพย์สินสาธารณะชื่อ Parent เพื่อรับรูปร่างหลักสำหรับกล่องข้อความ เพื่อให้ลูกค้าสามารถค้นหา Shape ที่เชื่อมโยงจาก TextBox ที่เกี่ยวข้อง
การสร้างลิงค์
คลาส TextBox จัดเตรียมวิธี IsValidLinkTarget เพื่อตรวจสอบว่า TextBox สามารถเชื่อมโยงกับ 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 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 อาจเป็น Head, Middle หรือ Tail ของลำดับก็ได้
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีตรวจสอบว่า TextBox เป็น Head, Tail หรือ Middle ของลำดับหรือไม่:
// 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(); |