DataGridViewAutoSizeRowsMode DataGridViewAutoSizeRowsMode DataGridViewAutoSizeRowsMode DataGridViewAutoSizeRowsMode Enum

定义

定义指定如何调整行高的值。Defines values for specifying how the heights of rows are adjusted.

public enum class DataGridViewAutoSizeRowsMode
public enum DataGridViewAutoSizeRowsMode
type DataGridViewAutoSizeRowsMode = 
Public Enum DataGridViewAutoSizeRowsMode
继承
DataGridViewAutoSizeRowsModeDataGridViewAutoSizeRowsModeDataGridViewAutoSizeRowsModeDataGridViewAutoSizeRowsMode

字段

AllCells AllCells AllCells AllCells 7

将行高调整到适合行中所有单元格(包括标头单元格)的内容。The row heights adjust to fit the contents of all cells in the rows, including header cells.

AllCellsExceptHeaders AllCellsExceptHeaders AllCellsExceptHeaders AllCellsExceptHeaders 6

将行高调整到适合行中所有单元格(不包括标头单元格)的内容。The row heights adjust to fit the contents of all cells in the rows, excluding header cells.

AllHeaders AllHeaders AllHeaders AllHeaders 5

将行高调整到适合行标头的内容。The row heights adjust to fit the contents of the row header.

DisplayedCells DisplayedCells DisplayedCells DisplayedCells 11

将行高调整到适合屏幕上当前显示的行中所有单元格(包括标头单元格)的内容。The row heights adjust to fit the contents of all cells in rows currently displayed onscreen, including header cells.

DisplayedCellsExceptHeaders DisplayedCellsExceptHeaders DisplayedCellsExceptHeaders DisplayedCellsExceptHeaders 10

将行高调整到适合屏幕上当前显示的行中所有单元格(不包括标头单元格)的内容。The row heights adjust to fit the contents of all cells in rows currently displayed onscreen, excluding header cells.

DisplayedHeaders DisplayedHeaders DisplayedHeaders DisplayedHeaders 9

将行高调整到适合屏幕上当前显示的行标头的内容。The row heights adjust to fit the contents of the row headers currently displayed onscreen.

None None None None 0

行高不自动调整。The row heights do not automatically adjust.

示例

下面的代码示例设置单元格内容更改时自动调整其高度的行。The following code example sets rows to automatically resize their height whenever cell contents change. 新的行高度由所有行和列的内容。The new row height is determined from the contents of all rows and columns. 此代码示例摘自如何: 自动调整大小的单元格时的内容更改 Windows 窗体 DataGridView 控件中This code example is part of a larger example provided in How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control.

void AutoSizeRowsMode( Object^ /*sender*/, EventArgs^ /*es*/ )
{
   dataGridView1->AutoSizeRowsMode = DataGridViewAutoSizeRowsMode::AllCells;
}
private void AutoSizeRowsMode(Object sender, EventArgs es)
{
    dataGridView1.AutoSizeRowsMode =
        DataGridViewAutoSizeRowsMode.AllCells;
}
Private Sub AutoSizeRowsMode(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button7.Click

    DataGridView1.AutoSizeRowsMode = _
        DataGridViewAutoSizeRowsMode.AllCells

End Sub

注解

DataGridView控件可以重新调整行基于每个行的首选高度。The DataGridView control can resize its rows based on the preferred height of each row. 首选的行高度是该行中显示的最大的单元格值所需的最小高度。The preferred row height is the minimum height required to display the largest cell value in that row. 不同的大小模式,您可以指示使用哪个单元格计算新高度 (标头单元格或非标头单元格),以及是否调整所有行或当前显示的行的大小。Different size modes let you indicate which cells are used to calculate the new heights (either header cells or nonheader cells) and whether to resize all rows or only the rows that are currently displayed. 调整大小的行的子集可用于处理很多行数据时避免对性能产生负面影响。Resizing a subset of rows is useful to avoid a performance penalty when working with many rows of data.

基于内容的自动调整大小可阻止用户调整行高使用鼠标。Content-based automatic resizing prevents users from adjusting row heights with the mouse.

此枚举由DataGridView控制AutoSizeRowsMode属性和AutoResizeRows方法。This enumeration is used by the DataGridView control AutoSizeRowsMode property and AutoResizeRows method.

有关调整大小模式的详细信息,请参阅Windows 窗体 DataGridView 控件中的大小调整选项For more information about sizing modes, see Sizing Options in the Windows Forms DataGridView Control.

适用于

另请参阅