PreferredWidthEquals Method (PreferredWidth)

Determines whether the specified PreferredWidth is equal in value to the current PreferredWidth.

Namespace:  Aspose.Words.Tables
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public bool Equals(
	PreferredWidth other
)

Parameters

other
Type: Aspose.Words.TablesPreferredWidth

Return Value

Type: Boolean
Examples
Shows how to set the different preferred width settings.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a table row made up of three cells which have different preferred widths
Table table = builder.StartTable();

// Insert an absolute sized cell
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightYellow;
builder.Writeln("Cell at 40 points width");

PreferredWidth width = builder.CellFormat.PreferredWidth;
Console.WriteLine($"Width \"{width.GetHashCode()}\": {width.ToString()}");

// Insert a relative (percent) sized cell
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
builder.Writeln("Cell at 20% width");

// Each cell had its own PreferredWidth
Assert.False(builder.CellFormat.PreferredWidth.Equals(width));

width = builder.CellFormat.PreferredWidth;
Console.WriteLine($"Width \"{width.GetHashCode()}\": {width.ToString()}");

// Insert a auto sized cell
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.Auto;
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGreen;
builder.Writeln(
    "Cell automatically sized. The size of this cell is calculated from the table preferred width.");
builder.Writeln("In this case the cell will fill up the rest of the available space.");

doc.Save(ArtifactsDir + "DocumentBuilder.InsertCellsWithPreferredWidths.docx");
See Also