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. 使用不同的大小模式, 可以指示哪些单元格用于计算新的高度 (标头单元或 nonheader 单元) 以及是要调整所有行的大小还是仅调整当前显示的行的大小。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.

适用于

另请参阅