HtmlDocument.All HtmlDocument.All HtmlDocument.All HtmlDocument.All Property

Definition

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

public:
 property System::Windows::Forms::HtmlElementCollection ^ All { System::Windows::Forms::HtmlElementCollection ^ get(); };
public System.Windows.Forms.HtmlElementCollection All { get; }
member this.All : System.Windows.Forms.HtmlElementCollection
Public ReadOnly Property All As HtmlElementCollection

Property Value

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.

public void EnableAllElements()
{
    if (webBrowser1.Document != null)
    {
        foreach (HtmlElement pageElement in webBrowser1.Document.All)
        {
            pageElement.Enabled = true;
        }
    }
}
Private Sub EnableAllElements()
    If (WebBrowser1.Document IsNot Nothing) Then
        For Each PageElement As HtmlElement In WebBrowser1.Document.All
            PageElement.Enabled = True
        Next
    End If
End Sub

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

See also