DataRepeater.CurrentItemIndex 属性
获取或设置在 DataRepeater 控件的当前 DataRepeaterItem 。
命名空间: Microsoft.VisualBasic.PowerPacks
程序集: Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
<BrowsableAttribute(False)> _
Public Property CurrentItemIndex As Integer
[BrowsableAttribute(false)]
public int CurrentItemIndex { get; set; }
[BrowsableAttribute(false)]
public:
property int CurrentItemIndex {
int get ();
void set (int value);
}
[<BrowsableAttribute(false)>]
member CurrentItemIndex : int with get, set
function get CurrentItemIndex () : int
function set CurrentItemIndex (value : int)
属性值
类型:System.Int32
当前 DataRepeaterItem 的索引。
备注
使用此属性返回或更改 CurrentItem 的索引。 DataRepeater 控件的。 设置具有相同的索引到视图的 CurrentItemIndex 属性将 DataRepeaterItem 。
备注
使用了最小的滚动方法, DataRepeaterItem 完全将移动到视图。若要使该项与 DataRepeater的顶部,调用 ScrollItemIntoView 方法,指定 true 为 AlignWithTop 参数。
示例
下面的示例演示如何使用 CurrentItemIndex 属性将焦点设置到 DataRepeater 控件的项目,基于搜索的结果。 它,假设有一个名为 DataRepeater1的一个 DataRepeater 控件,名为 SearchTextBox和命名 SearchButton的 Button 的 TextBox ,并且, DataRepeater 绑定到 Northwind 数据库的 products 表的数据源。
Private Sub SearchButton_Click() Handles SearchButton.Click
Dim foundIndex As Integer
Dim searchString As String
searchString = SearchTextBox.Text
foundIndex = ProductsBindingSource.Find("ProductID",
searchString)
If foundIndex > -1 Then
DataRepeater1.CurrentItemIndex = foundIndex
Else
MsgBox("Item " & searchString & " not found.")
End If
End Sub
private void searchButton_Click(System.Object sender, System.EventArgs e)
{
int foundIndex;
string searchString;
searchString = searchTextBox.Text;
foundIndex = productsBindingSource.Find("ProductID", searchString);
if (foundIndex > -1)
{
dataRepeater1.CurrentItemIndex = foundIndex;
}
else
{
MessageBox.Show("Item " + searchString + " not found.");
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间