ConditionalStyleCollection Class

Represents a collection of ConditionalStyle objects.
Inheritance Hierarchy

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.2
public sealed class ConditionalStyleCollection : IEnumerable<ConditionalStyle>, 

The ConditionalStyleCollection type exposes the following members.

Public propertyCode exampleBottomLeftCell
Gets the bottom left cell style.
Public propertyCode exampleBottomRightCell
Gets the bottom right cell style.
Public propertyCode exampleCount
Gets the number of conditional styles in the collection.
Public propertyCode exampleEvenColumnBanding
Gets the even column banding style.
Public propertyCode exampleEvenRowBanding
Gets the even row banding style.
Public propertyCode exampleFirstColumn
Gets the first column style.
Public propertyCode exampleFirstRow
Gets the first row style.
Public propertyCode exampleItemInt32
Retrieves a ConditionalStyle object by index.
Public propertyCode exampleItemConditionalStyleType
Retrieves a ConditionalStyle object by conditional style type.
Public propertyCode exampleLastColumn
Gets the last column style.
Public propertyCode exampleLastRow
Gets the last row style.
Public propertyCode exampleOddColumnBanding
Gets the odd column banding style.
Public propertyCode exampleOddRowBanding
Gets the odd row banding style.
Public propertyCode exampleTopLeftCell
Gets the top left cell style.
Public propertyCode exampleTopRightCell
Gets the top right cell style.
Public methodCode exampleClearFormatting
Clears all conditional styles of the table style.
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object that can be used to iterate over all conditional styles in the collection.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)
It is not possible to add or remove items from this collection. It contains permanent set of items: one item for each value of the ConditionalStyleType enumeration type.
Shows how to work with certain area styles of a table.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a table, which we will partially style
Table table = builder.StartTable();
builder.Write("Cell 1, to be formatted");
builder.Write("Cell 2, to be formatted");
builder.Write("Cell 3, to be left unformatted");
builder.Write("Cell 4, to be left unformatted");

TableStyle tableStyle = (TableStyle)doc.Styles.Add(StyleType.Table, "MyTableStyle1");
// There is a different ways how to get conditional styles:
// by conditional style type
tableStyle.ConditionalStyles[ConditionalStyleType.FirstRow].Shading.BackgroundPatternColor = Color.AliceBlue;
// by index
tableStyle.ConditionalStyles[0].Borders.Color = Color.Black;
tableStyle.ConditionalStyles[0].Borders.LineStyle = LineStyle.DotDash;
Assert.AreEqual(ConditionalStyleType.FirstRow, tableStyle.ConditionalStyles[0].Type);
// directly from ConditionalStyleCollection
tableStyle.ConditionalStyles.FirstRow.ParagraphFormat.Alignment = ParagraphAlignment.Center;
// To see this in Word document select Total Row checkbox in Design Tab
tableStyle.ConditionalStyles.LastRow.BottomPadding = 10;
tableStyle.ConditionalStyles.LastRow.LeftPadding = 10;
tableStyle.ConditionalStyles.LastRow.RightPadding = 10;
tableStyle.ConditionalStyles.LastRow.TopPadding = 10;
// To see this in Word document select Last Column checkbox in Design Tab
tableStyle.ConditionalStyles.LastColumn.Font.Bold = true;

// List all possible style conditions
using (IEnumerator<ConditionalStyle> enumerator = tableStyle.ConditionalStyles.GetEnumerator())
    while (enumerator.MoveNext())
        ConditionalStyle currentStyle = enumerator.Current;
        if (currentStyle != null) Console.WriteLine(currentStyle.Type);

// Apply conditional style to the table and save
table.Style = tableStyle;

doc.Save(ArtifactsDir + "Table.WorkWithTableConditionalStyles.docx");
See Also