การทำงานกับTextBoxes
ใน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-C | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(); | |
System::SharedPtr<Shape> shape1 = System::MakeObject<Shape>(doc, ShapeType::TextBox); | |
System::SharedPtr<Shape> shape2 = System::MakeObject<Shape>(doc, ShapeType::TextBox); | |
System::SharedPtr<TextBox> textBox1 = shape1->get_TextBox(); | |
System::SharedPtr<TextBox> textBox2 = shape2->get_TextBox(); | |
if (textBox1->IsValidLinkTarget(textBox2)) | |
{ | |
textBox1->set_Next(textBox2); | |
} |
ตรวจสอบTextBoxลำดับ
มีหลายวิธีในการแสดงข้อความในรูปร่าง TextBoxอาจเป็นหัวกลางหรือหางของลำดับ.
ตัวอย่างรหัสต่อไปนี้แสดงวิธีการตรวจสอบว่าTextBoxเป็นหัวหางหรือตรงกลางของลำดับ:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(); | |
System::SharedPtr<Shape> shape = System::MakeObject<Shape>(doc, ShapeType::TextBox); | |
System::SharedPtr<TextBox> textBox = shape->get_TextBox(); | |
if ((textBox->get_Next() != nullptr) && (textBox->get_Previous() == nullptr)) | |
{ | |
std::cout << "The head of the sequence" << std::endl; | |
} | |
if ((textBox->get_Next() != nullptr) && (textBox->get_Previous() != nullptr)) | |
{ | |
std::cout << "The Middle of the sequence." << std::endl; | |
} | |
if ((textBox->get_Next() == nullptr) && (textBox->get_Previous() != nullptr)) | |
{ | |
std::cout << "The Tail of the sequence." << std::endl; | |
} |
แบ่งการเชื่อมโยง
โดยใช้วิธีการBreakForwardLinkคุณสามารถแบ่งการเชื่อมโยงไปยังTextBoxต่อไป.
ตัวอย่างรหัสต่อไปนี้แสดงวิธีการแบ่งการเชื่อมโยงสำหรับTextBox:
For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(); | |
System::SharedPtr<Shape> shape = System::MakeObject<Shape>(doc, ShapeType::TextBox); | |
System::SharedPtr<TextBox> textBox = shape->get_TextBox(); | |
// Break a forward link | |
textBox->BreakForwardLink(); | |
// Break a forward link by setting a null | |
textBox->set_Next(nullptr); | |
// Break a link, which leads to this textbox | |
if (textBox->get_Previous() != nullptr) | |
{ | |
textBox->get_Previous()->BreakForwardLink(); | |
} |