DataGridViewRowsAddedEventHandler DataGridViewRowsAddedEventHandler DataGridViewRowsAddedEventHandler DataGridViewRowsAddedEventHandler Delegate

定义

表示将用来处理 RowsAddedDataGridView 事件的方法。Represents the method that will handle the RowsAdded event of a DataGridView.

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

参数

sender
Object Object Object Object

事件源。The source of the event.

继承
DataGridViewRowsAddedEventHandlerDataGridViewRowsAddedEventHandlerDataGridViewRowsAddedEventHandlerDataGridViewRowsAddedEventHandler

示例

下面的代码示例使用DataGridViewRowsAddedEventHandler虚拟模式下的来存储已添加行的事实。The following code example uses a DataGridViewRowsAddedEventHandler in virtual mode to store the fact that a row has been added. 此示例是VirtualMode参考主题中提供的一个更大示例的一部分。This example is part of a larger example available in the VirtualMode reference topic.

void VirtualConnector::dataGridView1_RowsAdded
    (Object^ sender, DataGridViewRowsAddedEventArgs^ e)
{
    if (newRowNeeded)
    {
        newRowNeeded = false;
        numberOfRows = numberOfRows + 1;
    }
}
private void dataGridView1_RowsAdded(object sender,
     DataGridViewRowsAddedEventArgs e)
{
    if (newRowNeeded)
    {
        newRowNeeded = false;
        numberOfRows = numberOfRows + 1;
    }
}
Private Sub dataGridView1_RowsAdded(ByVal sender As Object, _
    ByVal e As DataGridViewRowsAddedEventArgs) _
    Handles dataGridView1.RowsAdded

    If newRowNeeded Then
        newRowNeeded = False
        numberOfRows = numberOfRows + 1
    End If
End Sub

注解

RowsAdded行添加DataGridView到控件时发生此事件。The RowsAdded event occurs when rows are added to a DataGridView control.

创建 DataGridViewRowsAddedEventHandler 委托时,需要标识将处理该事件的方法。When you create a DataGridViewRowsAddedEventHandler 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, see Handling and Raising Events.

扩展方法

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

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

适用于

另请参阅