DataGridViewColumn.Resizable DataGridViewColumn.Resizable DataGridViewColumn.Resizable DataGridViewColumn.Resizable Property

定义

获取或设置一个值,指示该列的大小是否可调。Gets or sets a value indicating whether the column is resizable.

public:
 virtual property System::Windows::Forms::DataGridViewTriState Resizable { System::Windows::Forms::DataGridViewTriState get(); void set(System::Windows::Forms::DataGridViewTriState value); };
public override System.Windows.Forms.DataGridViewTriState Resizable { get; set; }
member this.Resizable : System.Windows.Forms.DataGridViewTriState with get, set
Public Overrides Property Resizable As DataGridViewTriState

属性值

示例

下面的代码示例使用此属性来修复第三列的大小, 以使用户无法更改列宽。The following code example uses this property to fix the size of the third column so that the user cannot change the column width.

dataGridView1->Columns[ 2 ]->Resizable = DataGridViewTriState::False;

dataGridView1.Columns[2].Resizable =
    DataGridViewTriState.False;
DataGridView1.Columns(2).Resizable = DataGridViewTriState.False

注解

如果属性为False, 则用户将不能手动调整列宽。 ResizableIf the Resizable property is False, the user will not be able to manually adjust the column width.

默认情况下, Resizable属性值基于DataGridView.AllowUserToResizeColumns属性值。By default, the Resizable property value is based on the DataGridView.AllowUserToResizeColumns property value. 如果显式设置ResizableTrueFalse, 则将忽略控件值。If you explicitly set Resizable to True or False, however, the control value is ignored. 设置ResizableNotSet可还原值继承行为。Set Resizable to NotSet to restore the value-inheritance behavior.

由于NotSet还原值继承Resizable , 因此NotSet属性永远不会返回值, 除非该列尚未添加到DataGridView控件中。Because NotSet restores the value inheritance, the Resizable property will never return a NotSet value unless the column has not been added to a DataGridView control. 如果需要确定是否继承列的Resizable属性值, 请检查其State属性。If you need to determine whether the Resizable property value of a column is inherited, check its State property. 如果属性值ResizableSet包含标志, Resizable则不会继承属性值。 StateIf the State property value includes the ResizableSet flag, the Resizable property value is not inherited.

适用于

另请参阅