Partager via


DataRepeater.BeginResetItemTemplate, méthode

Mise à jour : novembre 2007

Commence un bloc de code qui vous permet de réinitialiser le ItemTemplate pour un contrôle DataRepeater.

Espace de noms :  Microsoft.VisualBasic.PowerPacks
Assembly :  Microsoft.VisualBasic.PowerPacks.Vs (dans Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntaxe

Public Sub BeginResetItemTemplate

Dim instance As DataRepeater

instance.BeginResetItemTemplate()
public void BeginResetItemTemplate()
public:
void BeginResetItemTemplate()
public function BeginResetItemTemplate()

Notes

Utilisez cette méthode lorsque vous souhaitez réinitialiser des propriétés d'un ItemTemplate au moment de l'exécution. Pour fermer le bloc, cette méthode doit être suivie de la méthode EndResetItemTemplate.

Exemples

L'exemple suivant montre comment appeler les méthodes BeginResetItemTemplate et EndResetItemTemplate du gestionnaire d'événements LayoutStyleChanged d'un contrôle DataRepeater. Cet exemple suppose qu'il existe un contrôle DataRepeater nommé DataRepeater1 sur un formulaire et qu'il contient deux contrôles TextBox nommés TextBox1 et 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();
}

Autorisations

Voir aussi

Référence

DataRepeater, classe

Membres DataRepeater

Microsoft.VisualBasic.PowerPacks, espace de noms

EndResetItemTemplate

Autres ressources

Introduction au contrôle DataRepeater (Visual Studio)