Visual Basic Power Packs
DataRepeater..::.CurrentItem Property

Gets the current DataRepeaterItem in a DataRepeater control.

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

Visual Basic (Declaration)
<BrowsableAttribute(False)> _
Public ReadOnly Property CurrentItem As DataRepeaterItem
Visual Basic (Usage)
Dim instance As DataRepeater
Dim value As DataRepeaterItem

value = instance.CurrentItem
C#
[BrowsableAttribute(false)]
public DataRepeaterItem CurrentItem { get; }
Visual C++
[BrowsableAttribute(false)]
public:
property DataRepeaterItem^ CurrentItem {
    DataRepeaterItem^ get ();
}
JScript
public function get CurrentItem () : DataRepeaterItem

Property Value

Type: Microsoft.VisualBasic.PowerPacks..::.DataRepeaterItem
The currently selected object.
Remarks

Use the CurrentItem property to change the controls or data on the currently selected DataRepeaterItem at run time.

Examples

The following example demonstrates how to use the CurrentItem property to make changes when an item is selected. It assumes that you have a form that contains a bound DataRepeater named DataRepeater1, a bound TextBox named UnitsInStockTextBox, and a Label named LowStockWarningLabel.

Visual Basic
Private Sub DataRepeater1_CurrentItemIndexChanged(ByVal sender _
 As Object, ByVal e As System.EventArgs) Handles _
 DataRepeater1.CurrentItemIndexChanged
    ' Exit if the control is first loading.
    If DataRepeater1.CurrentItem Is Nothing Then Exit Sub
    ' Check for zero or negative quantity.
    If _
     CDbl(DataRepeater1.CurrentItem.Controls("UnitsInStockTextBox").Text) _
     < 1 Then
        ' Display a the warning label on the form.
        Me.LowStockWarningLabel.Visible = True
    Else
        Me.LowStockWarningLabel.Visible = False
    End If
End Sub
C#
private void dataRepeater1_CurrentItemIndexChanged(object sender, System.EventArgs e)
{
    // Exit if the control is first loading.
    if (dataRepeater1.CurrentItem == null) { return; }
    // Check for zero quantity.
    if (dataRepeater1.CurrentItem.Controls["unitsInStockTextBox"].Text == "0") 
    // Display a the warning label on the form.
    {
        this.lowStockWarningLabel.Visible = true;
    }
    else
    {
        this.lowStockWarningLabel.Visible = false;
    }
}
Permissions

See Also

Reference

Other Resources

Tags :


Page view tracker