GetEffectiveValue

ListLevel.GetEffectiveValue method

Reports the string representation of the ListLevel object for the specified index of the list item. Parameters specify the NumberStyle and an optional format string used when Custom is specified.

public static string GetEffectiveValue(int index, NumberStyle numberStyle, 
    string customNumberStyleFormat)
ParameterTypeDescription
indexInt32The index of the list item (must be in the range from 1 to 32767).
numberStyleNumberStyleThe NumberStyle of the ListLevel object.
customNumberStyleFormatStringThe optional format string used when Custom is specified (e.g. “a, ç, ĝ, …”). In other cases, this parameter must be null or empty.

Return Value

The string representation of the ListLevel object, described by the numberStyle parameter and the customNumberStyleFormat parameter, in the list item at the position determined by the index parameter.

Exceptions

exceptioncondition
ArgumentExceptioncustomNumberStyleFormat is null or empty when the numberStyle is custom.-or- customNumberStyleFormat is not null or empty when the numberStyle is non-custom.-or- customNumberStyleFormat is invalid.
ArgumentOutOfRangeExceptionindex is out of range.

Examples

Shows how to get the format for a list with the custom number style.

Document doc = new Document(MyDir + "List with leading zero.docx");

ListLevel listLevel = doc.FirstSection.Body.Paragraphs[0].ListFormat.ListLevel;

string customNumberStyleFormat = string.Empty;

if (listLevel.NumberStyle == NumberStyle.Custom)
    customNumberStyleFormat = listLevel.CustomNumberStyleFormat;

Assert.AreEqual("001, 002, 003, ...", customNumberStyleFormat);

// We can get value for the specified index of the list item.
Assert.AreEqual("iv", ListLevel.GetEffectiveValue(4, NumberStyle.LowercaseRoman, null));
Assert.AreEqual("005", ListLevel.GetEffectiveValue(5, NumberStyle.Custom, customNumberStyleFormat));

See Also