Lucrul cu TextBoxes
În Aspose.Words, clasa TextBox este utilizată pentru a specifica modul în care textul este afișat în interiorul unei forme. Expune o proprietate publică numită Parent pentru a obține forma părinte pentru caseta de text, astfel încât clientul să poată găsi Shape legat din TextBox asociat.
Creați Un Link
Clasa TextBox oferă metoda IsValidLinkTarget pentru a verifica dacă TextBox poate fi legat de ținta Textbox.
Următorul exemplu de cod arată cum să verificați dacă TextBox
poate fi legat de caseta de text țintă:
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); | |
} |
Verificați Secvența TextBox
Există mai multe moduri de a afișa text într-o formă. TextBox poate fi capul, mijlocul sau coada unei secvențe.
Următorul exemplu de cod arată cum să verificați dacă TextBox este un cap, o coadă sau un mijloc al secvenței:
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; | |
} |
Rupe un Link
Folosind metoda BreakForwardLink puteți rupe legătura cu următorul TextBox.
Următorul exemplu de cod arată cum să rupi o legătură pentru un 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(); | |
} |