共用方式為


HtmlDocument.All 屬性

定義

會得到一個實例,該實例 HtmlElementCollection儲存文件中的所有 HtmlElement 物件。

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

屬性值

文件 HtmlElementCollection 中所有元素的

範例

以下程式碼範例遍歷文件中的所有元素,並 Enabled=True啟用預設被禁用的元素,阻止使用者在文件載入時輸入。 程式碼範例要求你的應用程式包含 WebBrowser 一個名為 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

備註

All 集合提供對 HTML 文件中任意元素的隨機存取,無論其在文件樹中的位置如何。 用它來存取 HTML 文件中的任何元素,無論是名稱、ID 或索引。 你也可以反覆檢視文件中的所有元素。

有些元素,如 HEADTITLE,永遠不會有名稱。 其他元素只有在 HTML 檔案作者指定時才會有名稱。 你可以透過 ID 或索引存取沒有名稱的元素。

你不能直接將元素加入 All 集合,因為 HTML 檔案中除了 HTML 標籤外的所有元素都必須有父元素。 使用 AppendChild 方法或 InnerHtml 屬性 on 來 HtmlElement 新增元素到樹中。

適用於

另請參閱