편집

다음을 통해 공유


DataGridView.AutoResizeColumnHeadersHeight Method

Definition

Adjusts the height of the column headers to fit the header contents.

Overloads

AutoResizeColumnHeadersHeight(Int32, Boolean, Boolean)

Adjusts the height of the column headers based on changes to the contents of the header in the specified column, optionally calculating the height with the expectation that the column and/or row header widths will subsequently be adjusted.

AutoResizeColumnHeadersHeight(Boolean, Boolean)

Adjusts the height of the column headers to fit their contents, optionally calculating the height with the expectation that the column and/or row header widths will subsequently be adjusted.

AutoResizeColumnHeadersHeight()

Adjusts the height of the column headers to fit the contents of the largest column header.

AutoResizeColumnHeadersHeight(Int32)

Adjusts the height of the column headers based on changes to the contents of the header in the specified column.

AutoResizeColumnHeadersHeight(Int32, Boolean, Boolean)

Source:
DataGridView.Methods.cs
Source:
DataGridView.Methods.cs
Source:
DataGridView.Methods.cs

Adjusts the height of the column headers based on changes to the contents of the header in the specified column, optionally calculating the height with the expectation that the column and/or row header widths will subsequently be adjusted.

protected:
 void AutoResizeColumnHeadersHeight(int columnIndex, bool fixedRowHeadersWidth, bool fixedColumnWidth);
protected void AutoResizeColumnHeadersHeight (int columnIndex, bool fixedRowHeadersWidth, bool fixedColumnWidth);
member this.AutoResizeColumnHeadersHeight : int * bool * bool -> unit
Protected Sub AutoResizeColumnHeadersHeight (columnIndex As Integer, fixedRowHeadersWidth As Boolean, fixedColumnWidth As Boolean)

Parameters

columnIndex
Int32

The index of the column header whose contents should be used to determine new height.

fixedRowHeadersWidth
Boolean

true to calculate the new height based on the current width of the row headers; false to calculate the height with the expectation that the row headers width will also be adjusted.

fixedColumnWidth
Boolean

true to calculate the new height based on the current width of the specified column; false to calculate the height with the expectation that the column width will also be adjusted.

Exceptions

columnIndex is not in the valid range of 0 to the number of columns minus 1.

Remarks

This method is useful if you want to control when the column headers resize if only the contents of the header in the specified column have changed as a result of user edits or changes to a bound data source. The height of the column headers is adjusted only once per method call if the content change requires it; if the contents of the column headers later change, the column headers will not automatically adjust. To set the column headers to automatically resize when their contents change, use the ColumnHeadersHeightSizeMode property.

For cell contents to wrap onto multiple lines when the column headers are resized, the cell style in effect for the cell must have a WrapMode property value of True.

This overload is protected and is designed to enable you to achieve ideal cell height-to-width ratios in a derived DataGridView class. If the fixedColumnWidth or fixedRowHeadersWidth parameters are false, the height of the column headers will be calculated with the expectation that you will call the methods such as AutoResizeColumns and AutoResizeRowHeadersWidth next.

For more information about programmatic resizing, see Sizing Options in the Windows Forms DataGridView Control.

See also

Applies to

AutoResizeColumnHeadersHeight(Boolean, Boolean)

Source:
DataGridView.Methods.cs
Source:
DataGridView.Methods.cs
Source:
DataGridView.Methods.cs

Adjusts the height of the column headers to fit their contents, optionally calculating the height with the expectation that the column and/or row header widths will subsequently be adjusted.

protected:
 void AutoResizeColumnHeadersHeight(bool fixedRowHeadersWidth, bool fixedColumnsWidth);
protected void AutoResizeColumnHeadersHeight (bool fixedRowHeadersWidth, bool fixedColumnsWidth);
member this.AutoResizeColumnHeadersHeight : bool * bool -> unit
Protected Sub AutoResizeColumnHeadersHeight (fixedRowHeadersWidth As Boolean, fixedColumnsWidth As Boolean)

Parameters

fixedRowHeadersWidth
Boolean

true to calculate the new height based on the current width of the row headers; false to calculate the height with the expectation that the row headers width will also be adjusted.

fixedColumnsWidth
Boolean

true to calculate the new height based on the current column widths; false to calculate the height with the expectation that the column widths will also be adjusted.

Remarks

This method is useful if you want to control when the column headers resize. The height of the column headers is adjusted only once per method call; if the contents of the column headers later change, the column headers will not automatically adjust. To set the column headers to automatically resize when their contents change, use the ColumnHeadersHeightSizeMode property.

For cell contents to wrap onto multiple lines when the column headers are resized, the cell style in effect for the cell must have a WrapMode property value of True.

This overload is protected and is designed to enable you to achieve ideal cell height-to-width ratios in a derived DataGridView class. If the fixedColumnsWidth or fixedRowHeadersWidth parameters are false, the height of the column headers will be calculated with the expectation that you will call the methods such as AutoResizeColumns and AutoResizeRowHeadersWidth next.

For more information about programmatic resizing, see Sizing Options in the Windows Forms DataGridView Control.

See also

Applies to

AutoResizeColumnHeadersHeight()

Source:
DataGridView.Methods.cs
Source:
DataGridView.Methods.cs
Source:
DataGridView.Methods.cs

Adjusts the height of the column headers to fit the contents of the largest column header.

public:
 void AutoResizeColumnHeadersHeight();
public void AutoResizeColumnHeadersHeight ();
member this.AutoResizeColumnHeadersHeight : unit -> unit
Public Sub AutoResizeColumnHeadersHeight ()

Examples

The following code example demonstrates how to resize column headers and rows as a result of a button click.

void Button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   // Resize the height of the column headers. 
   dataGridView1->AutoResizeColumnHeadersHeight();

   // Resize all the row heights to fit the contents of all non-header cells.
   dataGridView1->AutoResizeRows(
         DataGridViewAutoSizeRowsMode::AllCellsExceptHeaders);
}
private void button1_Click(object sender, System.EventArgs e)
{
    // Resize the height of the column headers. 
    dataGridView1.AutoResizeColumnHeadersHeight();

    // Resize all the row heights to fit the contents of all non-header cells.
    dataGridView1.AutoResizeRows(
        DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders);
}
Private Sub button1_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles button1.Click

    ' Resize the height of the column headers. 
    dataGridView1.AutoResizeColumnHeadersHeight()

    ' Resize all the row heights to fit the contents of all 
    ' non-header cells.
    dataGridView1.AutoResizeRows( _
        DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders)

End Sub

Remarks

This method is useful if you want to control when the column headers resize. The height of the column headers is adjusted only once per method call; if the contents of the column headers later change, the column headers will not automatically adjust. To set the column headers to automatically resize when their contents change, use the ColumnHeadersHeightSizeMode property.

For cell contents to wrap onto multiple lines when the column headers are resized, the cell style in effect for the cell must have a WrapMode property value of True.

For more information about programmatic resizing, see Sizing Options in the Windows Forms DataGridView Control.

See also

Applies to

AutoResizeColumnHeadersHeight(Int32)

Source:
DataGridView.Methods.cs
Source:
DataGridView.Methods.cs
Source:
DataGridView.Methods.cs

Adjusts the height of the column headers based on changes to the contents of the header in the specified column.

public:
 void AutoResizeColumnHeadersHeight(int columnIndex);
public void AutoResizeColumnHeadersHeight (int columnIndex);
member this.AutoResizeColumnHeadersHeight : int -> unit
Public Sub AutoResizeColumnHeadersHeight (columnIndex As Integer)

Parameters

columnIndex
Int32

The index of the column containing the header with the changed content.

Exceptions

columnIndex is not in the valid range of 0 to the number of columns minus 1.

Remarks

This method is useful if you want to control when the column headers resize if only the contents of the header in the specified column have changed as a result of user edits or changes to a bound data source. The height of the column headers is adjusted only once per method call if the content change requires it; if the contents of the column headers later change, the column headers will not automatically adjust. To set the column headers to automatically resize when their contents change, use the ColumnHeadersHeightSizeMode property.

For cell contents to wrap onto multiple lines when the column headers are resized, the cell style in effect for the cell must have a WrapMode property value of True.

For more information about programmatic resizing, see Sizing Options in the Windows Forms DataGridView Control.

See also

Applies to