ListBox.ScrollIntoView(Object) 方法

定義

讓此物件捲動進入檢視。

public:
 void ScrollIntoView(System::Object ^ item);
public void ScrollIntoView (object item);
member this.ScrollIntoView : obj -> unit
Public Sub ScrollIntoView (item As Object)

參數

item
Object

要捲動的物件。

範例

下列範例示範如何使用 ScrollIntoView 方法,將清單方塊中的專案捲動至檢視區。

private void ScrollIntoView(object sender, RoutedEventArgs e)
{
    var index = cbScrollIntoView.SelectedIndex;
    var item = lbScrollIntoView.Items.GetItemAt(index);
    lbScrollIntoView.ScrollIntoView(item);
}
Private Sub ScrollIntoView(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim index = cbScrollIntoView.SelectedIndex
    Dim item = lbScrollIntoView.Items.GetItemAt(index)
    lbScrollIntoView.ScrollIntoView(item)
End Sub

備註

如果物件看不到,則會對齊檢視區頂端或底部。

適用於