DataGridView - autoSizeColumnsMode Property (System - Windows.forms) Microsoft Learn
DataGridView - autoSizeColumnsMode Property (System - Windows.forms) Microsoft Learn
21– 23/05/2024
Đăng ký ngay T
/ DataGridView / Properties / C# S
DataGridView.AutoSize
ColumnsMode Property
Reference
Feedback
Definition
Examples
Remarks
Applies to
See also
Definition
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms.dll
C# = Sao chép
public
System.Windows.Forms.DataGridViewAutoSizeColum
AutoSizeColumnsMode { get; set; }
Property Value
DataGridViewAutoSizeColumnsMode
Exceptions
InvalidEnumArgumentException
The specified value when setting this property is not a
valid DataGridViewAutoSizeColumnsMode value.
InvalidOperationException
The specified value when setting this property is
ColumnHeader, column headers are hidden, and at
least one visible column has an AutoSizeMode
property value of NotSet.
-or-
Examples
The following code example illustrates how to use
this property in a master/detail scenario where two
DataGridView controls display data from two tables in
a parent/child relationship. In this example, the
column sizing mode for the master control is None,
and the column widths are programmatically
initialized to fit the loaded values. The details control
is set to an automatic column sizing mode so that
columns will adjust automatically whenever the
values change (for example, when the user changes
the current row in the parent table). This example is
part of a larger example available in How to: Create a
Master/Detail Form Using Two Windows Forms
DataGridView Controls.
C# = Sao chép
Remarks
This property lets you configure the control so that
column widths are automatically adjusted either to fill
the control or to fit cell contents. Size adjustments
occur in fill mode whenever the width of the control
changes. 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.
Applies to
Sản phẩm Phiên bản
.NET 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1,
Framework 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
See also
DataGridViewAutoSizeColumnsMode
FillWeight
DataGridView Control (Windows Forms)
Sự cố mở tài liệu
Tiếng Việt
0 Chủ đề S