DataRepeater.BeginResetItemTemplate (Método)
Comienza un bloque de código que permite restablecer ItemTemplate para un control DataRepeater.
Espacio de nombres: Microsoft.VisualBasic.PowerPacks
Ensamblado: Microsoft.VisualBasic.PowerPacks.Vs (en Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintaxis
'Declaración
Public Sub BeginResetItemTemplate
public void BeginResetItemTemplate()
public:
void BeginResetItemTemplate()
member BeginResetItemTemplate : unit -> unit
public function BeginResetItemTemplate()
Comentarios
Utilice este método si desea restablecer las propiedades de un ItemTemplate en tiempo de ejecución. Este método debe ir seguido por el EndResetItemTemplate método para cerrar el bloque.
Ejemplos
En el ejemplo siguiente se muestra cómo llamar a la BeginResetItemTemplate y EndResetItemTemplate métodos en el LayoutStyleChanged controlador de eventos de un DataRepeater control. Este ejemplo requiere que haya un DataRepeater control denominado DataRepeater1 en un formulario y que contienen dos TextBox controles denominados TextBox1 y 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();
}
Seguridad de .NET Framework
- Plena confianza para el llamador inmediato. Un código de confianza parcial no puede utilizar este miembro. Para obtener más información, vea Utilizar bibliotecas de código que no es de plena confianza.
Vea también
Referencia
Microsoft.VisualBasic.PowerPacks (Espacio de nombres)