Free Support Forum - aspose.com

Placeholders collection returning Dictionary entries

Hello, The following code fragment is used to iterate across the collection of Placeholder entries in the Placeholders collection in a Slide object:

foreach (object ph in sld.Placeholders)

{

if (ph != null && ph is TextHolder)

{

TextHolder th = ph as TextHolder;

if (th.AlternativeText == altText)

{

return th;

}

}

}

However, what is returned from the iterator is a System.Collections.DictionaryEntry object, not a Placeholder or TextHolder item. In fact, what is returned can't even be casted to one of the other types. The VS.NET debugger shows that the Placeholders collection contains 2 TextHolder objects but these are not what is returned via the iterator. I'm using the 2.4.9 version of Slides.

THanks

Mark

DictionaryEntry.Value contains placeholder object.
Also you can use normal for loop to get each placeholder by index.

for (int i = 0; i < sld.Placeholders.Count; i++)
{
TextHolder th = sld.Placeholders[ i ] as TextHolder;

}