DataRepeater.CurrentItemIndex Property
Gets or sets the current DataRepeaterItem in a DataRepeater control.
Namespace: Microsoft.VisualBasic.PowerPacks
Assembly: Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)
Syntax
'Declaration
<BrowsableAttribute(False)> _
Public Property CurrentItemIndex As Integer
'Usage
Dim instance As DataRepeater
Dim value As Integer
value = instance.CurrentItemIndex
instance.CurrentItemIndex = value
[BrowsableAttribute(false)]
public int CurrentItemIndex { get; set; }
[BrowsableAttribute(false)]
public:
property int CurrentItemIndex {
int get ();
void set (int value);
}
public function get CurrentItemIndex () : int
public function set CurrentItemIndex (value : int)
Property Value
Type: System.Int32
The index of the current DataRepeaterItem.
Remarks
Use this property to return or change the index of the CurrentItem in a DataRepeater control. Setting the CurrentItemIndex property scrolls the DataRepeaterItem that has the equivalent index into view.
Note
The DataRepeaterItem will be scrolled fully into view using a minimum scroll strategy. To align the item with the top of the DataRepeater, call the ScrollItemIntoView method, specifying true for the AlignWithTop parameter.
Examples
The following example demonstrates how to use the CurrentItemIndex property to set the focus to an item in a DataRepeater control, depending on the results of a search. It assumes that you have a DataRepeater control named DataRepeater1, a TextBox named SearchTextBox, and a Button named SearchButton, and that the DataRepeater is bound to a data source for the Northwind database Products table.
Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) 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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.VisualBasic.PowerPacks Namespace