DataGridViewAutoSizeModeEventHandler DataGridViewAutoSizeModeEventHandler DataGridViewAutoSizeModeEventHandler DataGridViewAutoSizeModeEventHandler Delegate

定义

表示将对 AutoSizeRowsModeChangedRowHeadersWidthSizeModeChangedDataGridView 事件进行处理的方法。Represents the method that will handle the AutoSizeRowsModeChanged or RowHeadersWidthSizeModeChanged events of a DataGridView.

public delegate void DataGridViewAutoSizeModeEventHandler(System::Object ^ sender, DataGridViewAutoSizeModeEventArgs ^ e);
public delegate void DataGridViewAutoSizeModeEventHandler(object sender, DataGridViewAutoSizeModeEventArgs e);
type DataGridViewAutoSizeModeEventHandler = delegate of obj * DataGridViewAutoSizeModeEventArgs -> unit
Public Delegate Sub DataGridViewAutoSizeModeEventHandler(sender As Object, e As DataGridViewAutoSizeModeEventArgs)

参数

sender
Object Object Object Object

事件源。The source of the event.

继承
DataGridViewAutoSizeModeEventHandlerDataGridViewAutoSizeModeEventHandlerDataGridViewAutoSizeModeEventHandlerDataGridViewAutoSizeModeEventHandler

示例

下面的代码演示如何处理AutoSizeRowsModeChanged事件。The following code demonstrates how to handle the AutoSizeRowsModeChanged event.

void WatchRowsModeChanges( Object^ /*sender*/, DataGridViewAutoSizeModeEventArgs^ modeEvent )
{
   Label^ label = dynamic_cast<Label^>(flowLayoutPanel1->Controls[ currentLayoutName ]);
   if ( modeEvent->PreviousModeAutoSized )
   {
      label->Text = String::Format( "changed to a different {0}{1}", label->Name, dataGridView1->AutoSizeRowsMode );
   }
   else
   {
      label->Text = String::Concat( label->Name, dataGridView1->AutoSizeRowsMode );
   }
}


private void WatchRowsModeChanges(object sender,
    DataGridViewAutoSizeModeEventArgs modeEvent)
{
    Label label =
        (Label)flowLayoutPanel1.Controls[currentLayoutName];

    if (modeEvent.PreviousModeAutoSized)
    {
        label.Text = "changed to a different " +
            label.Name +
            dataGridView1.AutoSizeRowsMode.ToString();
    }
    else
    {
        label.Text = label.Name +
            dataGridView1.AutoSizeRowsMode.ToString();
    }
}
Private Sub WatchRowsModeChanges(ByVal sender As Object, _
    ByVal modeEvent As DataGridViewAutoSizeModeEventArgs) _
    Handles DataGridView1.AutoSizeRowsModeChanged

    Dim label As Label = CType(FlowLayoutPanel1.Controls _
        (currentLayoutName), Label)

    If modeEvent.PreviousModeAutoSized Then
        label.Text = "changed to different " & label.Name & _
            DataGridView1.AutoSizeRowsMode.ToString()
    Else
        label.Text = label.Name & _
            DataGridView1.AutoSizeRowsMode.ToString()
    End If
End Sub

注解

AutoSizeRowsModeChanged引发事件时的值AutoSizeRowsMode属性的DataGridView控件发生更改。The AutoSizeRowsModeChanged event is raised when the value of the AutoSizeRowsMode property of the DataGridView control changes. RowHeadersWidthSizeModeChanged引发事件时的值RowHeadersWidthSizeMode属性更改。The RowHeadersWidthSizeModeChanged event is raised when the value of the RowHeadersWidthSizeMode property changes.

创建 DataGridViewAutoSizeModeEventHandler 委托时,需要标识将处理该事件的方法。When you create a DataGridViewAutoSizeModeEventHandler delegate, you identify the method that will handle the event. 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。To associate the event with your event handler, add an instance of the delegate to the event. 除非移除了该委托,否则每当发生该事件时就会调用事件处理程序。The event handler is called whenever the event occurs, unless you remove the delegate. 有关事件处理程序委托的详细信息,请参阅有关事件处理程序委托的信息处理和引发事件For more information about event-handler delegates, information about event-handler delegates, see Handling and Raising Events.

Extension Methods

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.

适用于

另请参阅