Spread WPF 17
Spread WPF Documentation / Developer's Guide / Managing the User Interface / Using Shrink to Fit
In This Topic
    Using Shrink to Fit
    In This Topic

    The shrink to fit feature attempts to display all the text in the cell. The font size is reduced if the text is too long for the visible area of the cell.

    The following image shows the difference between a cell that supports shrink to fit and a cell that does not. Cell B2 supports the shrink to fit option. Cell B3 sets the ShrinkToFit property to false.

    An image showing two cells, in which one cell supports shrink to fit and the other does not

    Using Code

    The following example sets the ShrinkToFit property to true in cell B2 and false in cell B3.

    CS
    Copy Code
    gcSpreadSheet1.Sheets[0].Cells[1,1].Text = "Shrink To Fit Test";
    gcSpreadSheet1.Sheets[0].Cells[1, 1].ShrinkToFit = true;
    gcSpreadSheet1.Sheets[0].Cells[2, 1].Text = "Shrink To Fit Test";
    gcSpreadSheet1.Sheets[0].Cells[2, 1].ShrinkToFit = false;
    gcSpreadSheet1.Invalidate();
    
    VB.NET
    Copy Code
    GcSpreadSheet1.Sheets(0).Cells(1,1).Text = "Shrink To Fit Test"
    GcSpreadSheet1.Sheets(0).Cells(1,1).ShrinkToFit = True
    GcSpreadSheet1.Sheets(0).Cells(2,1).Text = "Shrink To Fit Test"
    GcSpreadSheet1.Sheets(0).Cells(2,1).ShrinkToFit = False
    GcSpreadSheet1.Invalidate()
    
    See Also