共用方式為


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 不支援事件。

備註

LayoutStyle屬性DataRepeater控制項可以決定是否DataRepeater項目會以垂直或水平的格式顯示。 當這個屬性變更時,您可以使用LayoutStyleChanged若要重新排列子系的事件處理常式中的控制項ItemTemplate以配合新的版面配置。

如需如何處理事件的詳細資訊,請參閱處理和引發事件

範例

下列範例顯示如何回應LayoutStyleChanged事件處理常式中的事件。 此範例中您需要DataRepeater名為控制項DataRepeater1上表單,它包含兩個TextBox控制項名為TextBox1和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();
}

.NET Framework 安全性

請參閱

參考

DataRepeater 類別

Microsoft.VisualBasic.PowerPacks 命名空間

LayoutStyle

其他資源

DataRepeater 控制項簡介 (Visual Studio)

如何:變更 DataRepeater 控制項的配置 (Visual Studio)