DataRepeater.LayoutStyleChanged (Evento)

Actualización: noviembre 2007

Se produce cuando cambia el valor de la propiedad LayoutStyle.

Espacio de nombres:  Microsoft.VisualBasic.PowerPacks
Ensamblado:  Microsoft.VisualBasic.PowerPacks.Vs (en Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintaxis

Public Event LayoutStyleChanged As EventHandler

Dim instance As DataRepeater
Dim handler As EventHandler

AddHandler instance.LayoutStyleChanged, handler
public event EventHandler LayoutStyleChanged
public:
 event EventHandler^ LayoutStyleChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
JScript no admite eventos.

Comentarios

La propiedad LayoutStyle de un control DataRepeater determina si se muestran los elementos DataRepeater en un formato vertical u horizontal. Cuando esta propiedad cambia, puede utilizar el controlador de eventos LayoutStyleChanged a fin de reorganizar los controles secundarios en ItemTemplate para que se ajusten al nuevo diseño.

Para obtener más información sobre cómo controlar los eventos, vea Utilizar eventos.

Ejemplos

En el ejemplo siguiente se muestra cómo responder al evento LayoutStyleChanged en un controlador de eventos. Este ejemplo requiere que tenga un control DataRepeater denominado DataRepeater1 en un formulario con dos controles TextBox denominados TextBox1 y TextBox2.

Private Sub DataRepeater1_LayoutStyleChanged(ByVal sender As Object, _
 ByVal e As System.EventArgs) Handles DataRepeater1.LayoutStyleChanged
    ' Call a method to re-initialize the template.
    DataRepeater1.BeginResetItemTemplate()
    If DataRepeater1.LayoutStyle = _
     PowerPacks.DataRepeaterLayoutStyles.Vertical Then
        ' Change the height of the template and rearrange the controls.
        DataRepeater1.ItemTemplate.Height = 150
        DataRepeater1.ItemTemplate.Controls(TextBox1.Name).Location = _
         New Point(20, 40)
        DataRepeater1.ItemTemplate.Controls(TextBox2.Name).Location = _
         New Point(150, 40)
    Else
        ' Change the width of the template and rearrange the controls.
        DataRepeater1.ItemTemplate.Width = 150
        DataRepeater1.ItemTemplate.Controls(TextBox1.Name).Location = _
         New Point(40, 20)
        DataRepeater1.ItemTemplate.Controls(TextBox2.Name).Location = _
         New Point(40, 150)
    End If
    ' Apply the changes to the template.
    DataRepeater1.EndResetItemTemplate()
End Sub
private void dataRepeater1_LayoutStyleChanged_1(object sender, EventArgs e)
{
    // Call a method to re-initialize the template.
    dataRepeater1.BeginResetItemTemplate();
    if (dataRepeater1.LayoutStyle == DataRepeaterLayoutStyles.Vertical)
    // Change the height of the template and rearrange the controls.
    {
        dataRepeater1.ItemTemplate.Height = 150;
        dataRepeater1.ItemTemplate.Controls["TextBox1"].Location = new Point(20, 40);
        dataRepeater1.ItemTemplate.Controls["TextBox2"].Location = new Point(150, 40);
    }
    else
    {
        // Change the width of the template and rearrange the controls.
        dataRepeater1.ItemTemplate.Width = 150;
        dataRepeater1.ItemTemplate.Controls["TextBox1"].Location = new Point(40, 20);
        dataRepeater1.ItemTemplate.Controls["TextBox2"].Location = new Point(40, 150);
    }
    // Apply the changes to the template.
    dataRepeater1.EndResetItemTemplate();
}

Permisos

Vea también

Referencia

DataRepeater (Clase)

DataRepeater (Miembros)

Microsoft.VisualBasic.PowerPacks (Espacio de nombres)

LayoutStyle

Otros recursos

Introducción al control DataRepeater (Visual Studio)

Cómo: Cambiar el diseño de un control DataRepeater (Visual Studio)