Skip to main content
All docs
V23.2

HtmlContentControl.FocusElement(String, Boolean) Method

Sets focus to or removes focus from the element with the specified ID.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public void FocusElement(
    string elementId,
    bool focused = true
)

Parameters

Name Type Description
elementId String

The ID of the element to be focused.

Optional Parameters

Name Type Default Description
focused Boolean True

true to focus an element; false to remove focus from the element.

Remarks

A focusable element receives focus on a mouse click. You can also use the Tab/Shift+Tab key to navigate between focusable HTML elements.

The FocusElement method allows you to focus or unfocus a specific element in code.

The following HTML elements are focusable:

  • An embedded editor. Use the input tag to embed editors in the HTML-based UI.
  • An HTML element that has the tabindex attribute specified.

See the following topic for information on how to customize HTML elements in CSS that are in the focused state: CSS Styles: State Selectors - Focused State.

See Also