HtmlElement.ScrollIntoView(Boolean) Metoda

Definice

Prochází dokument obsahující tento prvek, dokud horní nebo dolní okraj tohoto prvku není zarovnán s oknem dokumentu.

public:
 void ScrollIntoView(bool alignWithTop);
public void ScrollIntoView (bool alignWithTop);
member this.ScrollIntoView : bool -> unit
Public Sub ScrollIntoView (alignWithTop As Boolean)

Parametry

alignWithTop
Boolean

Pokud true, zobrazí se horní část objektu v horní části okna. Pokud false, zobrazí se dolní část objektu v dolní části okna.

Příklady

Následující příklad kódu najde prvek podle názvu a prochází stránku tak, aby horní část elementu byla zarovnaná s horní částí viditelné stránky.

private void ScrollToElement(String elemName)
{
    if (webBrowser1.Document != null)
    {
        HtmlDocument doc = webBrowser1.Document;
        HtmlElementCollection elems = doc.All.GetElementsByName(elemName);
        if (elems != null && elems.Count > 0)
        {
            HtmlElement elem = elems[0];

            elem.ScrollIntoView(true);
        }
    }
}
Private Sub ScrollToElement(ByVal ElemName As String)
    If (WebBrowser1.Document IsNot Nothing) Then
        With WebBrowser1.Document
            Dim Elems As HtmlElementCollection = .All.GetElementsByName(ElemName)
            If (Not Elems Is Nothing And Elems.Count > 0) Then
                Dim Elem As HtmlElement = Elems(0)

                Elem.ScrollIntoView(True)
            End If
        End With
    End If
End Sub

Platí pro

Viz také