HtmlDocument.All Property

Definition

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

C#
public System.Windows.Forms.HtmlElementCollection All { get; }

Property Value

The HtmlElementCollection of all elements in the document.

Examples

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.

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

Remarks

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.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also