DataRepeater.ScrollItemIntoView 方法 (Int32)
捲動指定DataRepeaterItem到檢視中DataRepeater控制項。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
Public Sub ScrollItemIntoView ( _
index As Integer _
)
public void ScrollItemIntoView(
int index
)
public:
void ScrollItemIntoView(
int index
)
member ScrollItemIntoView :
index:int -> unit
public function ScrollItemIntoView(
index : int
)
參數
index
類型:Int32DataRepeaterItem 的索引。
例外狀況
例外狀況 | 條件 |
---|---|
ArgumentOutOfRangeException | 指定的值index小於 0 或大於ItemCount-1。 |
備註
呼叫ScrollItemIntoView方法,以顯示特定DataRepeaterItem中控制項的可見部分。 不會選取項目。 若要選取的項目,設定CurrentItemIndex屬性。
項目將會最小捲動演算法中,捲動到檢視它不一定要對齊控制項的頂端。 若要對齊控制項的頂端的項目,請呼叫多載ScrollItemIntoView方法alignWithTop參數設定為true。
範例
下列程式碼範例示範如何進行第一次顯示的項目中目前選取的項目DataRepeater控制項。 這裡假設您有包含表單的DataRepeater名為控制項DataRepeater1和Button名為控制項SynchButton。
Private Sub SynchButton_Click() Handles SynchButton.Click
' If the first displayed item is not the current item.
If DataRepeater1.FirstDisplayedItemIndex <>
DataRepeater1.CurrentItemIndex Then
' Make it the current item.
DataRepeater1.CurrentItemIndex =
DataRepeater1.FirstDisplayedItemIndex
' Align it with the top of the control.
DataRepeater1.ScrollItemIntoView(
DataRepeater1.FirstDisplayedItemIndex, True)
End If
End Sub
private void synchButton_Click(System.Object sender, System.EventArgs e)
{
// If the first displayed item is not the current item.
if (dataRepeater1.FirstDisplayedItemIndex != dataRepeater1.CurrentItemIndex)
// Make it the current item.
{
dataRepeater1.CurrentItemIndex = dataRepeater1.FirstDisplayedItemIndex;
// Align it with the top of the control.
dataRepeater1.ScrollItemIntoView(dataRepeater1.FirstDisplayedItemIndex, true);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間