DataGridView.AutoResizeRowHeadersWidth Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adjusts the width of the row headers to fit the header contents.
Overloads
AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode) |
Adjusts the width of the row headers using the specified size mode. |
AutoResizeRowHeadersWidth(Int32, DataGridViewRowHeadersWidthSizeMode) |
Adjusts the width of the row headers based on changes to the contents of the header in the specified row and using the specified size mode. |
AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode, Boolean, Boolean) |
Adjusts the width of the row headers using the specified size mode, optionally calculating the width with the expectation that the row and/or column header widths will subsequently be adjusted. |
AutoResizeRowHeadersWidth(Int32, DataGridViewRowHeadersWidthSizeMode, Boolean, Boolean) |
Adjusts the width of the row headers based on changes to the contents of the header in the specified row and using the specified size mode, optionally calculating the width with the expectation that the row and/or column header widths will subsequently be adjusted. |
AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode)
Adjusts the width of the row headers using the specified size mode.
public:
void AutoResizeRowHeadersWidth(System::Windows::Forms::DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode);
public void AutoResizeRowHeadersWidth (System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode);
member this.AutoResizeRowHeadersWidth : System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode -> unit
Public Sub AutoResizeRowHeadersWidth (rowHeadersWidthSizeMode As DataGridViewRowHeadersWidthSizeMode)
Parameters
- rowHeadersWidthSizeMode
- DataGridViewRowHeadersWidthSizeMode
One of the DataGridViewRowHeadersWidthSizeMode values.
Exceptions
rowHeadersWidthSizeMode
has the value EnableResizing or DisableResizing.
rowHeadersWidthSizeMode
is not a valid DataGridViewRowHeadersWidthSizeMode value.
Remarks
This method is useful if you want to control when the row headers resize. The width of the row headers is adjusted only once per method call; if the contents of the row headers later change, the row headers will not automatically adjust. To set the row headers to automatically resize when their contents change, use the RowHeadersWidthSizeMode property.
This method lets you specify a sizing mode that calculates the new width based on values in a limited set of headers, such as those in displayed rows only. This improves performance when the control contains a large number of rows.
For more information about programmatic resizing, see Sizing Options in the Windows Forms DataGridView Control.
See also
Applies to
AutoResizeRowHeadersWidth(Int32, DataGridViewRowHeadersWidthSizeMode)
Adjusts the width of the row headers based on changes to the contents of the header in the specified row and using the specified size mode.
public:
void AutoResizeRowHeadersWidth(int rowIndex, System::Windows::Forms::DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode);
public void AutoResizeRowHeadersWidth (int rowIndex, System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode);
member this.AutoResizeRowHeadersWidth : int * System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode -> unit
Public Sub AutoResizeRowHeadersWidth (rowIndex As Integer, rowHeadersWidthSizeMode As DataGridViewRowHeadersWidthSizeMode)
Parameters
- rowIndex
- Int32
The index of the row header with the changed content.
- rowHeadersWidthSizeMode
- DataGridViewRowHeadersWidthSizeMode
One of the DataGridViewRowHeadersWidthSizeMode values.
Exceptions
rowIndex
is not in the valid range of 0 to the number of rows minus 1.
rowHeadersWidthSizeMode
has the value EnableResizing or DisableResizing
rowHeadersWidthSizeMode
is not a valid DataGridViewRowHeadersWidthSizeMode value.
Examples
The following code example illustrates how to resize the row header widths based on changes to the contents of the first row header. This code example is part of a larger example provided in How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control.
void SizeFirstRowHeaderToAllHeaders( Object^ /*sender*/, EventArgs^ /*e*/ )
{
dataGridView1->AutoResizeRowHeadersWidth(0, DataGridViewRowHeadersWidthSizeMode::AutoSizeToAllHeaders);
}
private void SizeFirstRowHeaderToAllHeaders(Object sender, EventArgs e)
{
dataGridView1.AutoResizeRowHeadersWidth(
0, DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
}
Private Sub SizeFirstRowHeaderToAllHeaders(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button8.Click
DataGridView1.AutoResizeRowHeadersWidth( _
DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders)
End Sub
Remarks
This method is useful if you want to control when the row headers resize if only the contents of the header in the specified row have changed as a result of user edits or changes to a bound data source. The width of the row headers is adjusted only once per method call if the content change requires it; if the contents of the row headers later change, the row headers will not automatically adjust. To set the row headers to automatically resize when their contents change, use the RowHeadersWidthSizeMode property.
This method lets you specify a sizing mode that calculates the new width based on values in a limited set of headers, such as those in displayed rows only. This improves performance when the control contains a large number of rows.
For more information about programmatic resizing, see Sizing Options in the Windows Forms DataGridView Control.
See also
Applies to
AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode, Boolean, Boolean)
Adjusts the width of the row headers using the specified size mode, optionally calculating the width with the expectation that the row and/or column header widths will subsequently be adjusted.
protected:
void AutoResizeRowHeadersWidth(System::Windows::Forms::DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowsHeight);
protected void AutoResizeRowHeadersWidth (System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowsHeight);
member this.AutoResizeRowHeadersWidth : System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode * bool * bool -> unit
Protected Sub AutoResizeRowHeadersWidth (rowHeadersWidthSizeMode As DataGridViewRowHeadersWidthSizeMode, fixedColumnHeadersHeight As Boolean, fixedRowsHeight As Boolean)
Parameters
- rowHeadersWidthSizeMode
- DataGridViewRowHeadersWidthSizeMode
One of the DataGridViewRowHeadersWidthSizeMode values.
- fixedColumnHeadersHeight
- Boolean
true
to calculate the new width based on the current height of the column headers; false
to calculate the width with the expectation that the height of the column headers will also be adjusted.
- fixedRowsHeight
- Boolean
true
to calculate the new width based on the current row heights; false
to calculate the width with the expectation that the row heights will also be adjusted.
Exceptions
rowHeadersWidthSizeMode
has the value EnableResizing or DisableResizing.
rowHeadersWidthSizeMode
is not a valid DataGridViewRowHeadersWidthSizeMode value.
Remarks
This method is useful if you want to control when the row headers resize. The width of the row headers is adjusted only once per method call; if the contents of the row headers later change, the row headers will not automatically adjust. To set the row headers to automatically resize when their contents change, use the RowHeadersWidthSizeMode property.
This method lets you specify a sizing mode that calculates the new width based on values in a limited set of headers, such as those in displayed rows only. This improves performance when the control contains a large number of rows.
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 fixedColumnHeadersHeight
or fixedRowsHeight
parameters are false
, the width of the row headers will be calculated with the expectation that you will call methods such as AutoResizeRows and AutoResizeColumnHeadersHeight next.
For more information about programmatic resizing, see Sizing Options in the Windows Forms DataGridView Control.
See also
Applies to
AutoResizeRowHeadersWidth(Int32, DataGridViewRowHeadersWidthSizeMode, Boolean, Boolean)
Adjusts the width of the row headers based on changes to the contents of the header in the specified row and using the specified size mode, optionally calculating the width with the expectation that the row and/or column header widths will subsequently be adjusted.
protected:
void AutoResizeRowHeadersWidth(int rowIndex, System::Windows::Forms::DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowHeight);
protected void AutoResizeRowHeadersWidth (int rowIndex, System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode rowHeadersWidthSizeMode, bool fixedColumnHeadersHeight, bool fixedRowHeight);
member this.AutoResizeRowHeadersWidth : int * System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode * bool * bool -> unit
Protected Sub AutoResizeRowHeadersWidth (rowIndex As Integer, rowHeadersWidthSizeMode As DataGridViewRowHeadersWidthSizeMode, fixedColumnHeadersHeight As Boolean, fixedRowHeight As Boolean)
Parameters
- rowIndex
- Int32
The index of the row containing the header with the changed content.
- rowHeadersWidthSizeMode
- DataGridViewRowHeadersWidthSizeMode
One of the DataGridViewRowHeadersWidthSizeMode values.
- fixedColumnHeadersHeight
- Boolean
true
to calculate the new width based on the current height of the column headers; false
to calculate the width with the expectation that the height of the column headers will also be adjusted.
- fixedRowHeight
- Boolean
true
to calculate the new width based on the current height of the specified row; false
to calculate the width with the expectation that the row height will also be adjusted.
Exceptions
rowIndex
is not in the valid range of 0 to the number of rows minus 1.
rowHeadersWidthSizeMode
has the value EnableResizing or DisableResizing.
rowHeadersWidthSizeMode
is not a valid DataGridViewRowHeadersWidthSizeMode value.
Remarks
This method is useful if you want to control when the row headers resize if only the contents of the header in the specified row have changed as a result of user edits or changes to a bound data source. The width of the row headers is adjusted only once per method call if the content change requires it; if the contents of the row headers later change, the row headers will not automatically adjust. To set the row headers to automatically resize when their contents change, use the RowHeadersWidthSizeMode property.
This method lets you specify a sizing mode that calculates the new width based on values in a limited set of headers, such as those in displayed rows only. This improves performance when the control contains a large number of rows.
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 fixedColumnHeadersHeight
or fixedRowHeight
parameters are false
, the width of the row headers will be calculated with the expectation that you will call methods such as AutoResizeRows and AutoResizeColumnHeadersHeight next.
For more information about programmatic resizing, see Sizing Options in the Windows Forms DataGridView Control.
See also
Applies to
.NET