windowsforms-devexpress-dot-xtraeditors-dot-htmlcontentcontrol-dot-findelementsbyclass-x28-system-dot-string-x29.md
Returns a list of HTML elements that are of the specified class.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public IEnumerable<DxHtmlElement> FindElementsByClass(
string class
)
Public Function FindElementsByClass(
class As String
) As IEnumerable(Of DxHtmlElement)
| Name | Type | Description |
|---|---|---|
| class | String |
The class of HTML elements to be retrieved.
|
| Type | Description |
|---|---|
| IEnumerable<DxHtmlElement> |
A list of HTML elements that are of the specified class.
|
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:
Hidden — Allows you to hide the 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 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);
}
Dim editors = htmlContentControl1.FindElementsByClass("editor")
For Each editor As DxHtmlElement In editors
editor.Style.SetBackgroundColor(Color.LightCoral)
editor.ParentElement.Style.SetBackgroundColor(Color.LightCoral)
Next editor
See the following topic for information on how to customize HTML elements with a specific class in CSS code: CSS Styles - Class Selector.
See Also