Aspose.Words.Examples.CSharp.Programming_Documents.Working_with_Tables.SpecifyHeightAndWidth.RetrievePreferredWidthType C# (CSharp) Method

RetrievePreferredWidthType() private static method

Shows how to retrieves the preferred width type of a table cell.
private static RetrievePreferredWidthType ( string dataDir ) : void
dataDir string
return void
        private static void RetrievePreferredWidthType(string dataDir)
        {
            // ExStart:RetrievePreferredWidthType
            Document doc = new Document(dataDir + "Table.SimpleTable.doc");

            // Retrieve the first table in the document.
            Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
            // ExStart:AllowAutoFit
            table.AllowAutoFit = true;
            // ExEnd:AllowAutoFit

            Cell firstCell = table.FirstRow.FirstCell;
            PreferredWidthType type = firstCell.CellFormat.PreferredWidth.Type;
            double value = firstCell.CellFormat.PreferredWidth.Value;

            // ExEnd:RetrievePreferredWidthType
            Console.WriteLine("\nTable preferred width type value is " + value.ToString());
        }
    }