Language

HtmlElementCollection.Item[] プロパティ

定義

コレクションから項目を取得します。

オーバーロード

名前 説明
Item[Int32]

数値インデックスを指定して、コレクションから項目を取得します。

Item[String]

名前を指定して、コレクションから項目を取得します。

注釈

HtmlElementCollection オブジェクトは読み取り専用です。 HTML ドキュメントに要素を追加するには、 InsertAdjacentElement や AppendChildなどのメソッドを使用します。

Item[Int32]

ソース:
HtmlElementCollection.cs
ソース:
HtmlElementCollection.cs
ソース:
HtmlElementCollection.cs
ソース:
HtmlElementCollection.cs
ソース:
HtmlElementCollection.cs

数値インデックスを指定して、コレクションから項目を取得します。

public:
 property System::Windows::Forms::HtmlElement ^ default[int] { System::Windows::Forms::HtmlElement ^ get(int index); };
public System.Windows.Forms.HtmlElement this[int index] { get; }
public System.Windows.Forms.HtmlElement? this[int index] { get; }
member this.Item(int) : System.Windows.Forms.HtmlElement
Default Public ReadOnly Property Item(index As Integer) As HtmlElement

パラメーター

index
Int32

コレクションから項目を取得する位置。

プロパティ値

数値インデックスを指定してコレクションの項目。

注釈

HtmlElementCollection内の要素は、ソース コードの順序であるとは限りません。 つまり、 DIV 要素が BODY タグ内の最初の要素であるからといって、コレクションの最初の要素が DIV 要素になるわけではありません。

適用対象

Item[String]

ソース:
HtmlElementCollection.cs
ソース:
HtmlElementCollection.cs
ソース:
HtmlElementCollection.cs
ソース:
HtmlElementCollection.cs
ソース:
HtmlElementCollection.cs

名前を指定して、コレクションから項目を取得します。

public:
 property System::Windows::Forms::HtmlElement ^ default[System::String ^] { System::Windows::Forms::HtmlElement ^ get(System::String ^ elementId); };
public System.Windows.Forms.HtmlElement this[string elementId] { get; }
public System.Windows.Forms.HtmlElement? this[string elementId] { get; }
member this.Item(string) : System.Windows.Forms.HtmlElement
Default Public ReadOnly Property Item(elementId As String) As HtmlElement

パラメーター

elementId
String

要素の Name または Id 属性。

プロパティ値

名前付き要素が見つかった場合は、 HtmlElement。 それ以外の場合は、 null。

例

次のコード例では、その名前を使用して FORM オブジェクトを検索し、そのデータをプログラムによってサーバーに送信します。 このコード例では、アプリケーションで WebBrowser という名前のwebBrowser1 コントロールをホストする必要があります。

private void SubmitForm(String formName)
{
    HtmlElementCollection elems = null;
    HtmlElement elem = null;

    if (webBrowser1.Document != null)
    {
        HtmlDocument doc = webBrowser1.Document;
        elems = doc.All.GetElementsByName(formName);
        if (elems != null && elems.Count > 0)
        {
            elem = elems[0];
            if (elem.TagName.Equals("FORM"))
            {
                elem.InvokeMember("Submit");
            }
        }
    }
}
Private Sub SubmitForm(ByVal FormName As String)
    Dim Elems As HtmlElementCollection
    Dim Elem As HtmlElement

    If (WebBrowser1.Document IsNot Nothing) Then
        With WebBrowser1.Document
            Elems = .All.GetElementsByName(FormName)
            If (Not Elems Is Nothing And Elems.Count > 0) Then
                Elem = Elems(0)
                If (Elem.TagName.Equals("FORM")) Then
                    Elem.InvokeMember("Submit")
                End If
            End If
        End With
    End If
End Sub

適用対象