DataRepeaterItem.ItemIndex Property

 

Gets the index of a DataRepeaterItem in a DataRepeater control.

Namespace:   Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

[BrowsableAttribute(false)]
public int ItemIndex { get; }
public:
[BrowsableAttribute(false)]
property int ItemIndex {
    int get();
}
[<BrowsableAttribute(false)>]
member ItemIndex : int with get
<BrowsableAttribute(False)>
Public ReadOnly Property ItemIndex As Integer

Property Value

Type: System.Int32

The index of the current DataRepeaterItem.

Remarks

Use this property to determine the index of each DataRepeaterItem as it is being processed in the DrawItem event of the DataRepeater control.

Examples

The following example demonstrates how to use the DrawItem event handler to display the ItemIndex for each item. It assumes that you have a form that contains a bound DataRepeater named DataRepeater1 with an unbound Label control named ItemLabel.

private void dataRepeater1_DrawItem(object sender, Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
{
    // Display the ItemIndex in the label.
    e.DataRepeaterItem.Controls["itemLabel"].Text = e.DataRepeaterItem.ItemIndex.ToString();
}
Private Sub DataRepeater1_DrawItem(
    ByVal sender As Object, 
    ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs
  ) Handles DataRepeater1.DrawItem

    ' Display the ItemIndex in the label.
    e.DataRepeaterItem.Controls("ItemLabel").Text = 
        CStr(e.DataRepeaterItem.ItemIndex)
End Sub

See Also

DataRepeaterItem Class
Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the DataRepeater Control (Visual Studio)

Return to top