Aspose::Words::Drawing::ShapeBase::set_Title method

ShapeBase::set_Title method

Sets the title (caption) of the current shape object.

void Aspose::Words::Drawing::ShapeBase::set_Title(const System::String & value)

Remarks

Default is empty string.

Cannot be null, but can be an empty string.

Examples

Shows how to set the title of a shape.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

// Create a shape, give it a title, and then add it to the document.
auto shape = System::MakeObject<Aspose::Words::Drawing::Shape>(doc, ShapeType::Cube);
shape->set_Width(200);
shape->set_Height(200);
shape->set_Title(u"My cube");

builder->InsertNode(shape);

// When we save a document with a shape that has a title,
// Aspose.Words will store that title in the shape's Alt Text.
doc->Save(get_ArtifactsDir() + u"Shape.Title.docx");

doc = System::MakeObject<Aspose::Words::Document>(System::String(get_ArtifactsDir() + u"Shape.Title.docx"));
shape = System::ExplicitCast<Aspose::Words::Drawing::Shape>(doc->GetChild(NodeType::Shape, 0, true));

ASSERT_EQ(shape->get_Title(), System::String::Empty);
ASSERT_EQ(shape->get_AlternativeText(), u"Title: My cube");

See Also