Evento DataRepeater.LayoutStyleChanged
Si verifica quando il valore della proprietà LayoutStyle cambia.
Spazio dei nomi: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintassi
'Dichiarazione
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 non supporta gli eventi.
Note
Il LayoutStyle proprietà di un DataRepeater controllo determina se DataRepeater gli elementi vengono visualizzati in un formato orizzontale o verticale. Quando questa proprietà viene modificata, è possibile utilizzare il LayoutStyleChanged gestore eventi per ridisporre l'elemento figlio di controlli nel ItemTemplate per adattarli al nuovo layout.
Per ulteriori informazioni su come gestire gli eventi, vedere Gestione e generazione di eventi.
Esempi
Nell'esempio seguente viene illustrato come rispondere alla LayoutStyleChanged evento in un gestore eventi. Si suppone di disporre di un DataRepeater controllo denominato DataRepeater1 in un form e che contiene due TextBox controlli denominati TextBox1 e 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();
}
Sicurezza di .NET Framework
- Attendibilità totale per il chiamante immediato. Impossibile utilizzare questo membro in codice parzialmente attendibile. Per altre informazioni, vedere Utilizzo di librerie da codice parzialmente attendibile.
Vedere anche
Riferimenti
Spazio dei nomi Microsoft.VisualBasic.PowerPacks
Altre risorse
Introduzione al controllo DataRepeater (Visual Studio)
Procedura: modificare il layout di un controllo DataRepeater (Visual Studio)