Zdarzenie DataRepeater.LayoutStyleChanged

Występuje po zmianie wartości właściwości LayoutStyle.

Przestrzeń nazw:  Microsoft.VisualBasic.PowerPacks
Zestaw:  Microsoft.VisualBasic.PowerPacks.Vs (w Microsoft.VisualBasic.PowerPacks.Vs.dll)

Składnia

'Deklaracja
Public Event LayoutStyleChanged As EventHandler
public event EventHandler LayoutStyleChanged
public:
 event EventHandler^ LayoutStyleChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
member LayoutStyleChanged : IEvent<EventHandler,
    EventArgs>
Język JScript nie obsługuje zdarzeń.

Uwagi

LayoutStyle Właściwości DataRepeater kontroli określa, czy DataRepeater elementy są wyświetlane w pionowej lub poziomej format.Zmiana tej właściwości można użyć LayoutStyleChanged obsługi zdarzeń, aby zmienić kolejność podrzędne kontrolek w ItemTemplate do nowego układu.

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i wywoływanie zdarzeń.

Przykłady

Poniższy przykład przedstawia, jak odpowiedzieć na LayoutStyleChanged zdarzenia programu obsługi zdarzeń.W tym przykładzie wymaga DataRepeater formantu o nazwie DataRepeater1 na formularzu i że zawiera on dwa TextBox formanty o nazwie TextBox1 i 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();
}

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

DataRepeater Klasa

Przestrzeń nazw Microsoft.VisualBasic.PowerPacks

LayoutStyle

Inne zasoby

Wprowadzenie do formantu DataRepeater (Visual Studio)

Porady: zmienianie układu formantu DataRepeater (Visual Studio)