Assembly: Microsoft.VisualBasic.PowerPacks (in Microsoft.VisualBasic.PowerPacks.dll)
Use the DataRepeater control. In effect, you are actually setting properties of the DataRepeaterItem objects that will be created at run time. The items that you see in the DataRepeater at run time are copied from this object as they are scrolled into view.property to set properties that determine the run time appearance of all items in a
At design time, when you select the section of the DataRepeater that contains the controls, the Properties window contains properties for the . For example, setting the BackColor property of the to Red causes all the items in the DataRepeater to be displayed with a red background.
Some common customizations for the DataRepeater control include displaying the rows in alternating colors and changing the color of a field based on a condition. The following example shows how to perform these customizations. 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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.