HtmlDocument.All Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets an instance of HtmlElementCollection, which stores all HtmlElement objects for the document.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public HtmlElementCollection All { get; }

Property Value

Type: System.Windows.Forms.HtmlElementCollection

The HtmlElementCollection of all elements in the document.

The All collection provides random access to any element in the HTML document, regardless of its position in the document tree. Use it to access any element in an HTML document by name, ID, or index. You may also iterate over all of the elements within a document.

Some elements, such as HEAD and TITLE, will never have names associated with them. All other elements will have names only if the author of the HTML file assigned them. You can access elements without names by ID or index.

You cannot add elements directly to the All collection, because all elements in an HTML file outside of the HTML tag must have a parent element. Use the AppendChild method or the InnerHtml property on HtmlElement to add new elements to the tree.

The following code example iterates through all of the elements in a document and sets Enabled=True, enabling any elements that may have been disabled by default to prevent user input while the document was loading. The code example requires that your application contains a WebBrowser control named WebBrowser1.

public void EnableAllElements()
    if (webBrowser1.Document != null)
        foreach (HtmlElement pageElement in webBrowser1.Document.All)
            pageElement.Enabled = true;

.NET Framework
Available since 2.0
Return to top