DataRepeater.CurrentItemIndex 屬性
取得或設定目前DataRepeaterItem中DataRepeater控制項。
命名空間: 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)
屬性值
類型:Int32
目前 DataRepeaterItem 的索引。
備註
使用這個屬性來傳回,或變更索引CurrentItem中DataRepeater控制項。 設定CurrentItemIndex屬性捲動DataRepeaterItem具有對等的索引檢視。
注意事項 |
---|
DataRepeaterItem會完全捲動到檢視,使用的最小捲動策略。若要使用的最上層項目對齊DataRepeater,呼叫ScrollItemIntoView方法中,指定true的AlignWithTop參數。 |
範例
下列範例示範如何使用CurrentItemIndex屬性,以將焦點設定為中的項目DataRepeater控制項,根據搜尋的結果。 這裡假設您有DataRepeater名為控制項DataRepeater1、TextBox名為SearchTextBox,和Button名為SearchButton,而且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 命名空間