Back to Devexpress

HtmlContentControl.FindElementsByTag(String) Method

windowsforms-devexpress-dot-xtraeditors-dot-htmlcontentcontrol-dot-findelementsbytag-x28-system-dot-string-x29.md

latest3.3 KB
Original Source

HtmlContentControl.FindElementsByTag(String) Method

Returns a list of HTML elements that have the specified tag.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public IEnumerable<DxHtmlElement> FindElementsByTag(
    string name
)
vb
Public Function FindElementsByTag(
    name As String
) As IEnumerable(Of DxHtmlElement)

Parameters

NameTypeDescription
nameString

The tag of HTML elements to be retrieved.

|

Returns

TypeDescription
IEnumerable<DxHtmlElement>

A list of HTML elements that have the specified tag.

|

Remarks

The FindElementsByTag method allows you to retrieve HTML elements (DxHtmlElement objects) that have the specified tag. A DxHtmlElement object exposes properties that you can use to change element display settings in code. The main properties include:

  • element.Hidden — Allows you to hide the element.
  • element.Style — Allows you to modify CSS style properties applied to the element. This object exposes the SetBackgroundColor, SetForeColor, and SetProperty methods for this purpose.

The following code locates and hides images (elements defined by the ‘img’ tag):

csharp
var elements = htmlContentControl.FindElementsByTag("img");
foreach (DxHtmlElement el in elements) {
    el.Hidden = true;
}
vb
Dim elements = htmlContentControl.FindElementsByTag("img")
For Each el As DxHtmlElement In elements
    el.Hidden = True
Next el

See the following topic for information on how to customize HTML elements with a specific ID in CSS code: CSS Styles - Tag Selector.

See Also

FindElementById(String)

FindElementsByClass(String)

FocusElement

ForEach(Action<DxHtmlElement>, Predicate<DxHtmlElement>)

HtmlContentControl Class

HtmlContentControl Members

DevExpress.XtraEditors Namespace