Used by the DataRepeater control to display data at run time.
Namespace:
Microsoft.VisualBasic.PowerPacks
Assembly:
Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Visual Basic (Declaration)
<DockingAttribute(DockingBehavior.Never)> _
Public Class DataRepeaterItem _
Inherits Panel
Dim instance As DataRepeaterItem
[DockingAttribute(DockingBehavior.Never)]
public class DataRepeaterItem : Panel
[DockingAttribute(DockingBehavior::Never)]
public ref class DataRepeaterItem : public Panel
public class DataRepeaterItem extends Panel
The DataRepeater control uses DataRepeaterItem objects to display each item in the control as it is scrolled into view. As soon as an item is scrolled out of view, the DataRepeaterItem is invalidated and replaced by a new DataRepeaterItem for the next visible item.
The layout and appearance of each item are based on the ItemTemplate property. As each DataRepeaterItem is rendered, you can modify the appearance in the DrawItem event.
Note: |
|---|
You should modify only the
DataRepeaterItem that can be accessed from the DrawItem event. Attempting to modify it outside the event or trying to create a new DataRepeaterItem can produce unexpected results.
|
The following example demonstrates how to use the DrawItem event handler to make changes when an item is scrolled into view. This example assumes that you have a DataRepeater control that is bound to the Products table in the Northwind database.
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.
DataRepeater1.ItemTemplate.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.
dataRepeater1.ItemTemplate.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;
}
}
System..::.Object
System..::.MarshalByRefObject
System.ComponentModel..::.Component
System.Windows.Forms..::.Control
System.Windows.Forms..::.ScrollableControl
System.Windows.Forms..::.Panel
Microsoft.VisualBasic.PowerPacks..::.DataRepeaterItem
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Reference
Other Resources