DataGridView.AutoSizeColumnModeChanged DataGridView.AutoSizeColumnModeChanged DataGridView.AutoSizeColumnModeChanged DataGridView.AutoSizeColumnModeChanged Event

定义

当列的 AutoSizeMode 属性值更改时发生。Occurs when the value of the AutoSizeMode property of a column changes.

public:
 event System::Windows::Forms::DataGridViewAutoSizeColumnModeEventHandler ^ AutoSizeColumnModeChanged;
public event System.Windows.Forms.DataGridViewAutoSizeColumnModeEventHandler AutoSizeColumnModeChanged;
member this.AutoSizeColumnModeChanged : System.Windows.Forms.DataGridViewAutoSizeColumnModeEventHandler 
Public Custom Event AutoSizeColumnModeChanged As DataGridViewAutoSizeColumnModeEventHandler 

示例

下面的代码示例演示如何使用此事件。The following code example illustrates the use of this event. 此示例摘自一个更大的示例中提供如何:操作 Windows 窗体 DataGridView 控件中的列This example is part of a larger example available in How to: Manipulate Columns in the Windows Forms DataGridView Control.

// Updated the criteria label.
void dataGridView_AutoSizeColumnModeChanged( Object^ /*sender*/, DataGridViewAutoSizeColumnModeEventArgs^ args )
{
   args->Column->DataGridView->Parent->Controls[ L"flowlayoutpanel" ]->Controls[ criteriaLabel ]->Text = String::Concat( criteriaLabel, args->Column->AutoSizeMode );
}
// Updated the criteria label.
private void dataGridView_AutoSizeColumnModeChanged(object sender,
    DataGridViewAutoSizeColumnModeEventArgs args)
{
    args.Column.DataGridView.Parent.
        Controls["flowlayoutpanel"].Controls[criteriaLabel].
        Text = criteriaLabel
        + args.Column.AutoSizeMode.ToString();
}
' Updated the criteria label.
Private Sub dataGridView_AutoSizeColumnCriteriaChanged( _
    ByVal sender As Object, _
    ByVal args As DataGridViewAutoSizeColumnModeEventArgs) _
    Handles DataGridView.AutoSizeColumnModeChanged

    args.Column.DataGridView.Parent. _
    Controls("flowlayoutpanel"). _
    Controls(criteriaLabel).Text = _
        criteriaLabel & args.Column.AutoSizeMode.ToString
End Sub

注解

有关如何处理事件的详细信息,请参阅处理和引发事件For more information about how to handle events, see Handling and Raising Events.

适用于

另请参阅