search/mag_sel search/close
Aspose::Words::Fields::DropDownItemCollection Class Reference

A collection of strings that represent all the items in a drop-down form field.

See also
Aspose::Words::Fields::FormField
Aspose::Words::Fields::FormField::get_DropDownItems
Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

#include <Aspose.Words.Cpp/Fields/DropDownItemCollection.h>

+ Inheritance diagram for Aspose::Words::Fields::DropDownItemCollection:

Public Types

using const_iterator = typename const_iterator
 
using iterator = typename iterator
 
using iterator_holder_type = List< String >
 

Public Member Functions

int32_t Add (String value)
 Adds a string to the end of the collection. More...
 
const_iterator begin () const noexcept
 
iterator begin () noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
void Clear ()
 Removes all elements from the collection. More...
 
bool Contains (String value)
 Determines whether the collection contains the specified value. More...
 
const_iterator end () const noexcept
 
iterator end () noexcept
 
int32_t get_Count ()
 Gets the number of elements contained in the collection. More...
 
SharedPtr< IEnumerator< String > > GetEnumerator () override
 Returns an enumerator object that can be used to iterate over all items in the collection. More...
 
virtual const TypeInfoGetType () const override
 
String idx_get (int32_t index)
 Gets or sets the element at the specified index. More...
 
void idx_set (int32_t index, String value)
 Gets or sets the element at the specified index. More...
 
int32_t IndexOf (String value)
 Returns the zero-based index of the specified value in the collection. More...
 
void Insert (int32_t index, String value)
 Inserts a string into the collection at the specified index. More...
 
virtual bool Is (const TypeInfo &target) const override
 
void Remove (String name)
 Removes the specified value from the collection. More...
 
void RemoveAt (int32_t index)
 Removes a value at the specified index. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Typedef Documentation

◆ const_iterator

◆ iterator

◆ iterator_holder_type

Member Function Documentation

◆ Add()

int32_t Aspose::Words::Fields::DropDownItemCollection::Add ( System::String  value)

Adds a string to the end of the collection.

Parameters
valueThe string to add to the end of the collection.
Returns
The zero-based index at which the new element is inserted.
Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ begin() [1/2]

const_iterator Aspose::Words::Fields::DropDownItemCollection::begin ( ) const
noexcept

◆ begin() [2/2]

iterator Aspose::Words::Fields::DropDownItemCollection::begin ( )
noexcept

◆ cbegin()

const_iterator Aspose::Words::Fields::DropDownItemCollection::cbegin ( ) const
noexcept

◆ cend()

const_iterator Aspose::Words::Fields::DropDownItemCollection::cend ( ) const
noexcept

◆ Clear()

void Aspose::Words::Fields::DropDownItemCollection::Clear ( )

Removes all elements from the collection.

Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ Contains()

bool Aspose::Words::Fields::DropDownItemCollection::Contains ( System::String  value)

Determines whether the collection contains the specified value.

Parameters
valueCase-sensitive value to locate.
Returns
True if the item is found in the collection; otherwise, false.
Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ end() [1/2]

const_iterator Aspose::Words::Fields::DropDownItemCollection::end ( ) const
noexcept

◆ end() [2/2]

iterator Aspose::Words::Fields::DropDownItemCollection::end ( )
noexcept

◆ get_Count()

int32_t Aspose::Words::Fields::DropDownItemCollection::get_Count ( )

Gets the number of elements contained in the collection.

Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ GetEnumerator()

System::SharedPtr<System::Collections::Generic::IEnumerator<System::String> > Aspose::Words::Fields::DropDownItemCollection::GetEnumerator ( )
overridevirtual

Returns an enumerator object that can be used to iterate over all items in the collection.

Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

Implements System::Collections::Generic::IEnumerable< class >.

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Fields::DropDownItemCollection::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ idx_get()

System::String Aspose::Words::Fields::DropDownItemCollection::idx_get ( int32_t  index)

Gets or sets the element at the specified index.

Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ idx_set()

void Aspose::Words::Fields::DropDownItemCollection::idx_set ( int32_t  index,
System::String  value 
)

Gets or sets the element at the specified index.

Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ IndexOf()

int32_t Aspose::Words::Fields::DropDownItemCollection::IndexOf ( System::String  value)

Returns the zero-based index of the specified value in the collection.

Parameters
valueThe case-sensitive value to locate.
Returns
The zero based index. Negative value if not found.
Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ Insert()

void Aspose::Words::Fields::DropDownItemCollection::Insert ( int32_t  index,
System::String  value 
)

Inserts a string into the collection at the specified index.

Parameters
indexThe zero-based index at which value is inserted.
valueThe string to insert.
Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ Is()

virtual bool Aspose::Words::Fields::DropDownItemCollection::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ Remove()

void Aspose::Words::Fields::DropDownItemCollection::Remove ( System::String  name)

Removes the specified value from the collection.

Parameters
nameThe case-sensitive value to remove.
Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ RemoveAt()

void Aspose::Words::Fields::DropDownItemCollection::RemoveAt ( int32_t  index)

Removes a value at the specified index.

Parameters
indexThe zero based index.
Examples

Shows how to insert a combo box field, and edit the elements in its item collection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a combo box, and then verify its collection of drop-down items.
// In Microsoft Word, the user will click the combo box,
// and then choose one of the items of text in the collection to display.
ArrayPtr<String> items = MakeArray<String>({u"One", u"Two", u"Three"});
SharedPtr<FormField> comboBoxField = builder->InsertComboBox(u"DropDown", items, 0);
SharedPtr<DropDownItemCollection> dropDownItems = comboBoxField->get_DropDownItems();
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_EQ(u"One", dropDownItems->idx_get(0));
ASSERT_EQ(1, dropDownItems->IndexOf(u"Two"));
ASSERT_TRUE(dropDownItems->Contains(u"Three"));
// There are two ways of adding a new item to an existing collection of drop-down box items.
// 1 - Append an item to the end of the collection:
dropDownItems->Add(u"Four");
// 2 - Insert an item before another item at a specified index:
dropDownItems->Insert(3, u"Three and a half");
ASSERT_EQ(5, dropDownItems->get_Count());
// Iterate over the collection and print every element.
{
SharedPtr<System::Collections::Generic::IEnumerator<String>> dropDownCollectionEnumerator = dropDownItems->GetEnumerator();
while (dropDownCollectionEnumerator->MoveNext())
{
std::cout << dropDownCollectionEnumerator->get_Current() << std::endl;
}
}
// There are two ways of removing elements from a collection of drop-down items.
// 1 - Remove an item with contents equal to the passed string:
dropDownItems->Remove(u"Four");
// 2 - Remove an item at an index:
dropDownItems->RemoveAt(3);
ASSERT_EQ(3, dropDownItems->get_Count());
ASSERT_FALSE(dropDownItems->Contains(u"Three and a half"));
ASSERT_FALSE(dropDownItems->Contains(u"Four"));
doc->Save(ArtifactsDir + u"FormFields.DropDownItemCollection.html");
// Empty the whole collection of drop-down items.
dropDownItems->Clear();

◆ Type()

static const System::TypeInfo& Aspose::Words::Fields::DropDownItemCollection::Type ( )
static