Skip to main content
All docs
V24.2

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

Modifies all child elements that match the given predicate. This method searches for matching elements recursively: first among this element’s Children collection, then among child elements of these children, and so on, until it reaches the lowermost elements.

Namespace: DevExpress.Utils.Html

Assembly: DevExpress.Data.Desktop.v24.2.dll

Declaration

public void ForEach(
    Action<DxHtmlElement> action,
    Predicate<DxHtmlElement> predicate = null
)

Parameters

Name Type Description
action Action<DxHtmlElement>

The action that modifies found elements.

Optional Parameters

Name Type Default Description
predicate Predicate<DxHtmlElement> null

The condition used to find HTML elements.

Remarks

The code below finds all elements with the "specs" class and disables them.

void OnHtmlElementMouseClick(object sender, WinExplorerViewHtmlElementHandledEventArgs e) {
    e.Element.ForEach(x => x.Disabled = true, p => p.ClassName == "specs");
}

If you want to modify only elements directly owned by the current HTML element, and prevent looking for elements outside the Children collection, add a second condition as shown below.

using System.Linq;

void OnHtmlElementMouseClick(object sender, WinExplorerViewHtmlElementHandledEventArgs e) {
    e.Element.ForEach(x => x.Disabled = true,
        p => p.ClassName == "specs"  && e.Element.Children.Contains(p) == true);
}
See Also