更新:2007 年 11 月
当 LayoutStyle 属性值更改时发生。
命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
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 不支持事件。
备注
DataRepeater 控件的 LayoutStyle 属性决定是按照垂直格式还是按照水平格式显示 DataRepeater 项。 当此属性更改时,可以使用 LayoutStyleChanged 事件处理程序来重新排列 ItemTemplate 中的子控件以适合新的布局。
有关如何处理事件的更多信息,请参见使用事件。
示例
下面的示例演示如何在事件处理程序中响应 LayoutStyleChanged 事件。 此示例要求您在窗体上有一个名为 DataRepeater1 的 DataRepeater 控件,且该控件包含两个名称分别为 TextBox1 和 TextBox2 的 TextBox 控件。
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();
}
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
另请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间