GetEffectiveValue

ListLevel.GetEffectiveValue method

Segnala la rappresentazione in formato stringa delListLeveloggetto per l’indice specificato dell’elemento dell’elenco. I parametri specificano l’NumberStyle e una stringa di formato opzionale utilizzata quandoCustom è specificato.

public static string GetEffectiveValue(int index, NumberStyle numberStyle, 
    string customNumberStyleFormat)
ParametroTipoDescrizione
indexInt32L’indice dell’elemento dell’elenco (deve essere compreso tra 1 e 32767).
numberStyleNumberStyleIlNumberStyle delListLevel oggetto.
customNumberStyleFormatStringLa stringa di formato facoltativa utilizzata quandoCustom è specificato (ad esempio “a, ç, ĝ, …”). In altri casi, questo parametro deve esserenull o vuoto.

Valore di ritorno

La rappresentazione della stringaListLevel oggetto, descritto dalnumberStyle parametro and ilcustomNumberStyleFormat parametro, nell’elemento dell’elenco nella posizione determinata dalindex parametro.

Eccezioni

eccezionecondizione
ArgumentExceptioncustomNumberStyleFormat Ènull o vuoto quando ilnumberStyle è personalizzato.-o- customNumberStyleFormat non ènull o vuoto quando ilnumberStyle non è personalizzato.-o- customNumberStyleFormat non è valido.
ArgumentOutOfRangeExceptionl’indice è fuori intervallo.

Esempi

Mostra come ottenere il formato per un elenco con lo stile numerico personalizzato.

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);

// Possiamo ottenere il valore per l'indice specificato dell'elemento dell'elenco.
Assert.AreEqual("iv", ListLevel.GetEffectiveValue(4, NumberStyle.LowercaseRoman, null));
Assert.AreEqual("005", ListLevel.GetEffectiveValue(5, NumberStyle.Custom, customNumberStyleFormat));

Guarda anche