DataRepeaterItemEventArgs 构造函数
初始化 DataRepeaterItemEventArgs 类的新实例。
命名空间: Microsoft.VisualBasic.PowerPacks
程序集: Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
Public Sub New ( _
item As DataRepeaterItem _
)
public DataRepeaterItemEventArgs(
DataRepeaterItem item
)
public:
DataRepeaterItemEventArgs(
DataRepeaterItem^ item
)
new :
item:DataRepeaterItem -> DataRepeaterItemEventArgs
public function DataRepeaterItemEventArgs(
item : DataRepeaterItem
)
参数
- item
类型:Microsoft.VisualBasic.PowerPacks.DataRepeaterItem
要绘制的项。
备注
使用 DrawItem 事件更改 DataRepeaterItem 对象的外观,它们移动到视图。
在运行时,可基于条件设置与外观相关的属性。 例如,在日程安排应用程序中,您可以更改某个项的背景颜色来警告用户该项已过期。 如果在条件语句的属性例如 If…Then,还必须使用 Else 子句指定外观,当条件不满足时。
示例
,当项滚动到视图中时,下面的示例演示如何使用 DrawItem 事件处理程序进行更改。 此示例假定您有一个 DataRepeater 控件,该控件绑定到 Northwind 数据库的 Products 表。
Private Sub DataRepeater1_DrawItem(
ByVal sender As Object,
ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs
) Handles DataRepeater1.DrawItem
' Alternate the back color.
If (e.DataRepeaterItem.ItemIndex Mod 2) <> 0 Then
' Apply the secondary back color.
e.DataRepeaterItem.BackColor = Color.AliceBlue
Else
' Apply the default back color.
e.DataRepeaterItem.BackColor = Color.White
End If
' Change the color of out-of-stock items to red.
If e.DataRepeaterItem.Controls(
UnitsInStockTextBox.Name).Text < 1 Then
e.DataRepeaterItem.Controls(UnitsInStockTextBox.Name).
BackColor = Color.Red
Else
e.DataRepeaterItem.Controls(UnitsInStockTextBox.Name).
BackColor = Color.White
End If
End Sub
private void dataRepeater1_DrawItem(object sender,
Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
{
// Alternate the back color.
if ((e.DataRepeaterItem.ItemIndex % 2) != 0)
// Apply the secondary back color.
{
e.DataRepeaterItem.BackColor = Color.AliceBlue;
}
else
{
// Apply the default back color.
e.DataRepeaterItem.BackColor = Color.White;
}
// Change the color of out-of-stock items to red.
if (e.DataRepeaterItem.Controls["unitsInStockTextBox"].Text == "0")
{
e.DataRepeaterItem.Controls["unitsInStockTextBox"].BackColor = Color.Red;
}
else
{
e.DataRepeaterItem.Controls["unitsInStockTextBox"].BackColor = Color.White;
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间