Export (0) Print
Expand All

HtmlWindowCollection Class

Represents the windows contained within another HtmlWindow.

System.Object
  System.Windows.Forms.HtmlWindowCollection

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public class HtmlWindowCollection : ICollection, 
	IEnumerable

The HtmlWindowCollection type exposes the following members.

  NameDescription
Public propertyCountGets the number of elements in the collection.
Public propertyItem[Int32]Retrieves a frame window by supplying the frame's position in the collection.
Public propertyItem[String]Retrieves a frame window by supplying the frame's name.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an enumerator that can iterate through all elements in the HtmlWindowCollection.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public Extension MethodAsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension MethodAsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension MethodCast<TResult>Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension MethodOfType<TResult>Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToInfrastructure. Copies the elements of the collection to an Array, starting at a particular Array index.
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedInfrastructure. Gets a value indicating whether access to the collection is synchronized (thread safe).
Explicit interface implemetationPrivate propertyICollection.SyncRootInfrastructure. Gets an object that can be used to synchronize access to the collection.
Top

An HTML document may consist of a FRAMESET that defines multiple fixed FRAME objects, each of which contains its own HTML page. Alternatively, a document may contain a number of IFRAME objects, which can position documents arbitrarily inside of other documents. FRAME objects and IFRAME objects are represented at their top-most level by an HtmlWindowCollection, which contains elements of type HtmlWindow.

HtmlWindowCollection supports the IEnumerator interface so that it can be used in loop constructs. It also defines an Item method, which allows access to the elements of the collection either via a method call or using standard array syntax.

If you create new windows with the Open or OpenNew methods, and the documents hosted by these windows contain FRAME or IFRAME elements, that these elements will appear in the HtmlWindowCollection of the parent page.

For more information on frames, see the documentation for the Frames property.

The following code example inspects each document within a page containing frames and creates a table of all of the outgoing hyperlinks from each page for future inspection.

		private void GetLinksFromFrames()
		{
			Hashtable linksTable = new Hashtable();
			string frameUrl;

			if (!(webBrowser1.Document == null))
			{
				HtmlWindow currentWindow = webBrowser1.Document.Window;
				if (currentWindow.Frames.Count > 0)
				{
					foreach (HtmlWindow frame in currentWindow.Frames)
					{
						frameUrl = frame.Url.ToString();
						Hashtable frameLinksHash = new Hashtable();

						linksTable.Add(frameUrl, frameLinksHash);
						foreach (HtmlElement hrefElement in frame.Document.Links)
						{
							frameLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url");
						}
					}
				}
				else
				{
					Hashtable docLinksHash = new Hashtable();
					linksTable.Add(webBrowser1.Document.Url.ToString(), docLinksHash);

                    foreach (HtmlElement hrefElement in webBrowser1.Document.Links)
					{
						docLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url");
					}
				}
			}
		}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft