DataRepeater.CurrentItem 属性

更新:2007 年 11 月

获取 DataRepeater 控件中的当前 DataRepeaterItem

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
<BrowsableAttribute(False)> _
Public ReadOnly Property CurrentItem As DataRepeaterItem
用法
Dim instance As DataRepeater
Dim value As DataRepeaterItem

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

属性值

类型:Microsoft.VisualBasic.PowerPacks.DataRepeaterItem

当前选定的对象。

备注

使用 CurrentItem 属性在运行时更改当前选定的 DataRepeaterItem 上的控件或数据。

示例

下面的示例演示在选定项时如何使用 CurrentItem 属性来进行更改。 假定您有一个窗体,其中包含一个名为 DataRepeater1 的绑定 DataRepeater、一个名为 UnitsInStockTextBox 的绑定 TextBox 以及一个名为 LowStockWarningLabel 的 Label

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
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;
    }
}

权限

另请参见

参考

DataRepeater 类

DataRepeater 成员

Microsoft.VisualBasic.PowerPacks 命名空间

CurrentItemIndexChanged

其他资源

DataRepeater 控件简介 (Visual Studio)