HtmlDocument.Images プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

HtmlElement オブジェクトのコレクション。ドキュメント内の各 IMG タグです。要素は、格納されている順序でコレクションから返されます。

Images は、HtmlElement オブジェクトのコレクションを返します。HtmlElement によって直接公開されていない ALT、SRC などの属性にアクセスするには、GetAttribute メソッドを使用します。
新しいイメージをドキュメントに追加するには、新しい IMG タグを文字列として作成し、以前に HTML DOM に追加された要素の InnerHtml プロパティに割り当てます。CreateElement メソッドを使用して、SetAttribute によってプロパティを設定し、AppendChild を使用して既存の要素の子として追加することもできます。

ドキュメント内のすべてのイメージの ALT 属性を調べて、値がまだ設定されていない場合は既定の ALT 属性を設定するコード例を次に示します。
Private Function GetImageUrls() As String() If (WebBrowser1.Document IsNot Nothing) Then Dim Urls(WebBrowser1.Document.Images.Count) As String For Each ImgElement As HtmlElement In WebBrowser1.Document.Images Urls(Urls.Length) = ImgElement.GetAttribute("SRC") Next GetImageUrls = Urls Else Dim Urls(0) As String GetImageUrls = Urls End If End Function
private string[] GetImageUrls() { if (webBrowser1.Document != null) { HtmlDocument doc = webBrowser1.Document; string[] urls = (string[])Array.CreateInstance(Type.GetType("System.String"), doc.Images.Count); foreach (HtmlElement imgElement in doc.Images) { urls[urls.Length] = imgElement.GetAttribute("src"); } return (urls); } else { return (new string[0]); } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlDocument.Images プロパティを検索する場合は、下記のリンクをクリックしてください。

- HtmlDocument.Images プロパティのページへのリンク