DataRepeater.LayoutStyleChanged 事件

LayoutStyle 属性值更改时发生。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
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>
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();
}

.NET Framework 安全性

请参见

参考

DataRepeater 类

Microsoft.VisualBasic.PowerPacks 命名空间

LayoutStyle

其他资源

DataRepeater 控件简介 (Visual Studio)

如何:更改 DataRepeater 控件的布局 (Visual Studio)