HtmlContentControl.FindElementsByClass(String) Method
Returns a list of HTML elements that are of the specified class.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v24.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
class | String | The class of HTML elements to be retrieved. |
Returns
Type | Description |
---|---|
IEnumerable<DxHtmlElement> | A list of HTML elements that are of the specified class. |
Remarks
You can use the ‘class’ attribute to assign an HTML element to a specific class in HTML markup:
<input class='editor' name='emailEdit' value='${Email}'/>
The FindElementsByClass
method allows you to retrieve HTML elements (DxHtmlElement
objects) that belong to the specified class. 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 theSetBackgroundColor
,SetForeColor
, andSetProperty
methods for this purpose.
The following code locates elements that belong to the “editor” class, and changes the background color of these elements and their parents:
var editors = htmlContentControl1.FindElementsByClass("editor");
foreach(DxHtmlElement editor in editors) {
editor.Style.SetBackgroundColor(Color.LightCoral);
editor.ParentElement.Style.SetBackgroundColor(Color.LightCoral);
}
See the following topic for information on how to customize HTML elements with a specific class in CSS code: CSS Styles - Class Selector.