DataRepeater.BeginResetItemTemplate 方法
更新:2007 年 11 月
开始一个代码块,该代码块允许您重置 DataRepeater 控件的 ItemTemplate。
命名空间: Microsoft.VisualBasic.PowerPacks
程序集: Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
Public Sub BeginResetItemTemplate
用法
Dim instance As DataRepeater
instance.BeginResetItemTemplate()
public void BeginResetItemTemplate()
public:
void BeginResetItemTemplate()
public function BeginResetItemTemplate()
备注
如果希望在运行时重置 ItemTemplate 的属性,请使用此方法。 此方法后面必须跟 EndResetItemTemplate 方法以关闭代码块。
示例
下面的示例演示如何在 DataRepeater 控件的 LayoutStyleChanged 事件处理程序中调用 BeginResetItemTemplate 和 EndResetItemTemplate 方法。 此示例要求您在窗体上有一个名为 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();
}
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
另请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间