Back to Devexpress

HtmlContentControl.CustomEditor Event

windowsforms-devexpress-dot-xtraeditors-dot-htmlcontentcontrol-c5d52a2a.md

latest5.8 KB
Original Source

HtmlContentControl.CustomEditor Event

Allows you to assign custom in-place editors (Repository Items) to individual <input> tags. The event is not in effect for <input> tags used to embed external controls.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Editor")]
public event CustomEditorEventHandler CustomEditor
vb
<DXCategory("Editor")>
Public Event CustomEditor As CustomEditorEventHandler

Event Data

The CustomEditor event's data class is DevExpress.XtraEditors.CustomEditorEventArgs.

Remarks

You can use the <input> HTML tag as a placeholder for external controls and in-place editors (Repository Items) that you want to display within a layout.

The following example defines two <input> tags. The first tag explicitly specifies a repositoryItemTextEdit1 object as the default in-place editor. The second tag implicitly specifies a date editor as the default in-place editor (based on the data type of the bound field):

html
<!-- Explicit text in-place editor (repositoryItemTextEdit1). -->
<input class="editor" value="${StringData}" name="repositoryItemTextEdit1"/>
<!-- Implicit in-place editor (date editor) selected based on the data type of the bound field. -->
<input class="editor" value="${OrderDate}"/>

The CustomEditor event allows you to assign in-place editors to <input> tags dynamically, and thus override the default editors explicitly or implicitly assigned to the tags.

csharp
RepositoryItemButtonEdit riButtonEdit;

riButtonEdit = new RepositoryItemButtonEdit();
htmlContentControl1.RepositoryItems.Add(riButtonEdit);
// Customize the button editor.
// ...

private void htmlContentControl1_CustomEditor(object sender, CustomEditorEventArgs e) {
    if (e.FieldName == "Password")
        e.RepositoryItem = riButtonEdit;
}
vb
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    riButtonEdit = New RepositoryItemButtonEdit()
    HtmlContentControl1.RepositoryItems.Add(riButtonEdit)
    ' Customize the button editor.
    ' ...
End Sub

Dim riButtonEdit As RepositoryItemButtonEdit

Private Sub HtmlContentControl1_CustomEditor(sender As Object, e As DevExpress.XtraEditors.CustomEditorEventArgs) _
    Handles HtmlContentControl1.CustomEditor
    If e.FieldName = "Password" Then
        e.RepositoryItem = riButtonEdit
    End If
End Sub

The e.FieldName event parameter identifies the currently processed input tag. It specifies the tag’s bound field name (the value argument of the <input> tag).

Use the e.RepositoryItem event parameter to specify an in-place editor for the current input tag. The in-place editor must be added to the HtmlContentControl.RepositoryItems collection or an external repository (see EditorContainer.ExternalRepository).

Use Separate In-place Editors to Display and Edit Values

The custom editor you specify in the CustomEditor event is used both when the editor is not active (browse mode), and active (edit mode). Handle the HtmlContentControl.CustomEditorForEditing event to specify an in-place editor only for edit mode.

Properties

Events

Methods

See Also

HtmlContentControl Class

HtmlContentControl Members

DevExpress.XtraEditors Namespace