HtmlElement::Parent Property

 

Gets the current element's parent element.

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

public:
property HtmlElement^ Parent {
	HtmlElement^ get();
}

Property Value

Type: System.Windows.Forms::HtmlElement^

The element above the current element in the HTML document's hierarchy.

The Parent property enables discovery of an element's context. It is most useful inside of event handlers such as Click, which can fire for any element anywhere in the document's object hierarchy.

The Parent property of the HTML element (the top of an HTML document) points back to itself. If you call Parent inside a loop, verify that the loop's break condition compares the type of the current element and the type of the Parent property, or else your code may execute an infinite loop.

The following code example finds all of the IMG tags in a document, and uses the Parent property to test whether the IMG is hyperlinked to another page; if it is, the code assigns the URL to the ALT attribute of the IMG tag, so that users can mouse over the image to see where it will take them.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: