Class ListStyle
Represents a list style in the Word document.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public class ListStyle : XDLSSerializableBase, IXDLSSerializable, IStyle
Examples
The following code example demonstrates how to
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Create a new list numbered list style
ListStyle listStyle = new ListStyle(document, ListType.Numbered);
//Set the name for the new list style
listStyle.Name = "UserdefinedList";
WListLevel levelOne = listStyle.Levels[0];
//Define the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab;
levelOne.NumberPrefix = "(";
levelOne.NumberSufix = ")";
levelOne.PatternType = ListPatternType.LowRoman;
levelOne.StartAt = 1;
levelOne.TabSpaceAfter = 5;
levelOne.NumberAlignment = ListNumberAlignment.Center;
document.ListStyles.Add(listStyle);
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add text to the paragraph
paragraph.AppendText("The list of pets available:");
//Add other paragraphs and apply the created new list style
paragraph = section.AddParagraph();
//Apply default numbered list style
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Dog");
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Cat");
//Continue last defined list
paragraph.ListFormat.ContinueListNumbering();
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Hamsters");
paragraph.ListFormat.ContinueListNumbering();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Turtles");
paragraph.ListFormat.ContinueListNumbering();
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Guinea Pigs");
paragraph.ListFormat.ContinueListNumbering();
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Ferrets");
paragraph.ListFormat.ContinueListNumbering();
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Fish");
paragraph.ListFormat.ContinueListNumbering();
//Save and close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Create a new list numbered list style
Dim listStyle As New ListStyle(document, ListType.Numbered)
'Set the name for the new list style
listStyle.Name = "UserdefinedList"
Dim levelOne As WListLevel = listStyle.Levels(0)
'Define the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab
levelOne.NumberPrefix = "("
levelOne.NumberSufix = ")"
levelOne.PatternType = ListPatternType.LowRoman
levelOne.StartAt = 1
levelOne.TabSpaceAfter = 5
levelOne.NumberAlignment = ListNumberAlignment.Center
document.ListStyles.Add(listStyle)
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add text to the paragraph
paragraph.AppendText("The list of pets available:")
'Add other paragraphs and apply the created new list style
paragraph = section.AddParagraph()
'Apply default numbered list style
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Dog")
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Cat")
'Continue last defined list
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Hamsters")
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Turtles")
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Guinea Pigs")
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Ferrets")
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Fish")
paragraph.ListFormat.ContinueListNumbering()
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Constructors
ListStyle(IWordDocument, ListType)
Initializes a new instance of the ListStyle class with the specified IWordDocument instance and the ListType.
Declaration
public ListStyle(IWordDocument doc, ListType listType)
Parameters
Type | Name | Description |
---|---|---|
IWordDocument | doc | The IWordDocument object. |
ListType | listType | The type of the list. |
Properties
Levels
Gets the collection of the levels in the list. Read-only.
Declaration
public ListLevelCollection Levels { get; }
Property Value
Type | Description |
---|---|
ListLevelCollection | The collection of list levels. |
ListType
Gets or sets the list type.
Declaration
public ListType ListType { get; set; }
Property Value
Type | Description |
---|---|
ListType | The ListType member that specifies the list type. |
Name
Gets or sets the name for the list style.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that represents the style name. |
StyleType
Gets the type of the list style. Read-only.
Declaration
public StyleType StyleType { get; }
Property Value
Type | Description |
---|---|
StyleType | The StyleTypemember that specifies the type of the style. |
Methods
Clone()
Creates a duplicate copy of this IStyle object.
Declaration
public IStyle Clone()
Returns
Type | Description |
---|---|
IStyle | The reference of the newly created IStyle object. |
CloneImpl()
Creates a duplicate copy of this ListStyle instance.
Declaration
protected override object CloneImpl()
Returns
Type | Description |
---|---|
System.Object | The reference of the new ListStyle instance. |
Overrides
CreateEmptyListStyle(IWordDocument, ListType, Boolean)
Creates a new empty list style for the specified document, with the list type and single level option.
Declaration
public static ListStyle CreateEmptyListStyle(IWordDocument doc, ListType listType, bool isOneLevelList)
Parameters
Type | Name | Description |
---|---|---|
IWordDocument | doc | The IWordDocument object. |
ListType | listType | The ListType for the new list style. |
System.Boolean | isOneLevelList | The boolean value specifying whether this list should have only one level. |
Returns
Type | Description |
---|---|
ListStyle | The newly created ListStyle instance. |
GetNearLevel(Int32)
Returns the WListLevel with the specified level number.
Declaration
public WListLevel GetNearLevel(int levelNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | levelNumber | The integer that specifies the level number. |
Returns
Type | Description |
---|---|
WListLevel | The WListLevel instance at the specified level number. |
Remarks
When the specified level number is greater than the number of levels in the list, then the last level in the list will be returned.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The level number cannot be less than zero. |
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
Overrides
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |
Overrides
Explicit Interface Implementations
IStyle.Close()
Declaration
void IStyle.Close()
IStyle.Remove()
Declaration
void IStyle.Remove()