次のサンプルコードは、このメソッドを使用して、実行時にコードによってセルのサイズを内容に合わせる方法を示します。このサンプルコードは、
GcMultiRow.AllowUserToResizeクラスに示されている詳細なコード例の一部を抜粋したものです。
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