DataRepeaterItemEventArgs Class
Provides data for the DrawItem event.
Inheritance Hierarchy
System.Object
System.EventArgs
Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
‘선언
Public Class DataRepeaterItemEventArgs _
Inherits EventArgs
public class DataRepeaterItemEventArgs : EventArgs
public ref class DataRepeaterItemEventArgs : public EventArgs
type DataRepeaterItemEventArgs =
class
inherit EventArgs
end
public class DataRepeaterItemEventArgs extends EventArgs
The DataRepeaterItemEventArgs type exposes the following members.
Constructors
Name | Description | |
---|---|---|
DataRepeaterItemEventArgs | Initializes a new instance of the DataRepeaterItemEventArgs class. |
Top
Properties
Name | Description | |
---|---|---|
DataRepeaterItem | Gets a DataRepeaterItem that provides the data for the DrawItem event of a DataRepeater control |
Top
Methods
Name | Description | |
---|---|---|
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
Use the DrawItem event to change the appearance of DataRepeaterItem objects as they are scrolled into view.
At run time, appearance-related properties can be set based on conditions. For example, in a scheduling application, you might change the background color of an item to warn users when an item is past due. If you set a property in a conditional statement such as If…Then, you must also use an Else clause to specify the appearance when the condition is not met.
Examples
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.
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;
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
Microsoft.VisualBasic.PowerPacks Namespace
Other Resources
Introduction to the DataRepeater Control (Visual Studio)
How to: Change the Appearance of a DataRepeater Control (Visual Studio)