DataGridViewAutoSizeModeEventHandler Delegado

Definición

Representa el método que controlará los eventos AutoSizeRowsModeChanged o RowHeadersWidthSizeModeChanged de un objeto DataGridView.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)

Parámetros

sender
Object

Origen del evento.The source of the event.

e
DataGridViewAutoSizeModeEventArgs

Objeto DataGridViewAutoSizeModeEventArgs que contiene los datos del evento.A DataGridViewAutoSizeModeEventArgs that contains the event data.

Herencia
DataGridViewAutoSizeModeEventHandler

Ejemplos

En el código siguiente se muestra cómo controlar AutoSizeRowsModeChanged el evento.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

Comentarios

El AutoSizeRowsModeChanged evento se desencadena cuando cambia el valor de AutoSizeRowsMode la propiedad del DataGridView control.The AutoSizeRowsModeChanged event is raised when the value of the AutoSizeRowsMode property of the DataGridView control changes. El RowHeadersWidthSizeModeChanged evento se desencadena cuando cambia el valor de RowHeadersWidthSizeMode la propiedad.The RowHeadersWidthSizeModeChanged event is raised when the value of the RowHeadersWidthSizeMode property changes.

Cuando se crea un delegado DataGridViewAutoSizeModeEventHandler, se identifica el método que controlará el evento.When you create a DataGridViewAutoSizeModeEventHandler delegate, you identify the method that will handle the event. Para asociar el evento al controlador, se debe agregar una instancia del delegado al evento.To associate the event with your event handler, add an instance of the delegate to the event. Siempre que se produce el evento, se llama a su controlador, a menos que se quite el delegado.The event handler is called whenever the event occurs, unless you remove the delegate. Para obtener más información acerca de los delegados de controladores de eventos, consulte controlar y provocar eventos.For more information about event-handler delegates, information about event-handler delegates, see Handling and Raising Events.

Métodos de extensión

GetMethodInfo(Delegate)

Obtiene un objeto que representa el método representado por el delegado especificado.Gets an object that represents the method represented by the specified delegate.

Se aplica a

Consulte también: