GrapeCity MultiRow Windows Forms Documentation
PerformVerticalAutoFit Method (Cell)
Example 


Programmatically fits the cell's size to its content in the vertical direction.
Syntax
Public Sub PerformVerticalAutoFit() 
Dim instance As Cell
 
instance.PerformVerticalAutoFit()
public void PerformVerticalAutoFit()
Exceptions
ExceptionDescription
System.InvalidOperationException

Executes this method when the GcMultiRow property is a null reference (Nothing in Visual Basic).

-or-

The Width or Height is zero.

-or-

This cell is beyond the boundary of the parent Section.

Remarks
This method provides the capability to automatically resize the cell programmatically.
Example
The following code example shows how to use this method to change the size to fit with code at run time. This code example is part of a larger example provided for the GcMultiRow.AllowUserToResize class.
void autoFitAllColumns_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.gcMultiRow1.ColumnHeaders[0].Cells.Count; i++)
            {
                Cell cell = this.gcMultiRow1.ColumnHeaders[0][i];

                // Auto change cell's width to fit cells contents.
                cell.PerformHorizontalAutoFit();
            }
        }

        void autoFitAllRows_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.gcMultiRow1.RowCount; i++)
            {
                Cell cell = this.gcMultiRow1.Rows[i][0];

                // Auto change cell's height to fit cells contents.
                cell.PerformVerticalAutoFit();
            }
        }
Private Sub autoFitAllColumns_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 
autoFitAllColumns.Click

        For i As Integer = 0 To Me.gcMultiRow1.ColumnHeaders(0).Cells.Count - 1
            Dim cell As Cell = Me.gcMultiRow1.ColumnHeaders(0)(i)

            ' Auto change cell's width to fit cells contents.
            cell.PerformHorizontalAutoFit()
        Next
    End Sub

    Private Sub autoFitAllRows_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 
autoFitAllRows.Click
        For i As Integer = 0 To Me.gcMultiRow1.RowCount - 1
            Dim cell As Cell = Me.gcMultiRow1.Rows(i)(0)

            ' Auto change cell's height to fit cells contents.
            cell.PerformVerticalAutoFit()
        Next
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Cell Class
Cell Members
PerformHorizontalAutoFit Method

 

 


Copyright © GrapeCity, inc. All rights reserved.