DataGridViewColumn.InheritedAutoSizeMode 属性


获取对该列有效的缩放模式。Gets the sizing mode in effect for the column.

 property System::Windows::Forms::DataGridViewAutoSizeColumnMode InheritedAutoSizeMode { System::Windows::Forms::DataGridViewAutoSizeColumnMode get(); };
public System.Windows.Forms.DataGridViewAutoSizeColumnMode InheritedAutoSizeMode { get; }
member this.InheritedAutoSizeMode : System.Windows.Forms.DataGridViewAutoSizeColumnMode
Public ReadOnly Property InheritedAutoSizeMode As DataGridViewAutoSizeColumnMode


作用于该列的 DataGridViewAutoSizeColumnMode 值。The DataGridViewAutoSizeColumnMode value in effect for the column.



列的自动调整大小行为取决于 InheritedAutoSizeMode 属性的值,该属性与除 NotSet之外的所有值 AutoSizeMode 属性的值相同,这表示该值是从 DataGridView.AutoSizeColumnsMode 属性继承而来的。The automatic sizing behavior of the column is determined by the value of the InheritedAutoSizeMode property, which is the same as the value of the AutoSizeMode property for all values except NotSet, which indicates that the value is inherited from the DataGridView.AutoSizeColumnsMode property instead.

FillInheritedAutoSizeMode 属性值时,该列将与该模式中的其他列一起调整,以便控件中的所有可见列都完全填充可用显示区域的水平宽度。When the InheritedAutoSizeMode property value is Fill, the column is resized along with other columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. 控件中的所有填充模式列都按其 FillWeight 属性值确定的比例划分可用空间。All fill-mode columns in the control divide the available space in proportions determined by their FillWeight property values. 有关列填充模式的详细信息,请参阅Windows 窗体 DataGridView 控件中的列填充模式For more information about column fill mode, see Column Fill Mode in the Windows Forms DataGridView Control.

InheritedAutoSizeMode 属性设置为除 None以外的任何其他值时,该列将管理其宽度,以便在不进行剪裁的情况下完全显示其单元值。When the InheritedAutoSizeMode property is set to any other value except None, the column will manage its width so that its cell values are fully displayed without clipping. 在基于内容的大小调整模式下,无论何时更改单元格内容,都将发生大小调整,如果 WrapMode 已启用,则每当行高发生变化时。In content-based sizing modes, size adjustments occur whenever cell contents change or, if WrapMode is enabled, whenever row heights change. 某些基于内容的大小调整模式允许您将调整大小限制为当前显示的行,以便提高性能。Some content-based sizing modes let you limit the size adjustment to the currently displayed rows in order to increase performance.

仅调整 Visible 属性值为 true 的列的大小,更改列的可见性不会导致调整大小。Only columns with a Visible property value of true are resized, and changing the visibility of a column does not cause resizing to occur. 此外,如果将列设置为自动调整大小,则用户无法用鼠标调整列宽。Additionally, when columns are set to automatically resize, the user cannot adjust the column widths with the mouse.

若要以编程方式调整列宽,请使用 DataGridView 控件的 AutoResizeColumnAutoResizeColumns 方法,或设置列 Width 属性。To adjust column widths programmatically, use the DataGridView control's AutoResizeColumn or AutoResizeColumns methods or set the column Width property.

有关基于内容的自动调整大小的详细信息,请参阅Windows 窗体 DataGridView 控件中的调整大小选项For more information about content-based automatic sizing, see Sizing Options in the Windows Forms DataGridView Control.