InplaceEditorEventArgs.InplaceEditorEx Property

Gets or sets the in-place editor which is invoked when an end-user adds a new appointment or edits an existing one “in place”.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v21.2.dll

Declaration

public ISchedulerInplaceEditorEx InplaceEditorEx { get; set; }

Property Value

Type Description
ISchedulerInplaceEditorEx

A ISchedulerInplaceEditorEx object which represents the in-place editor.

Remarks

By default, the SchedulerControl uses its internal in-place editor, which is inherited from the TextBox class. However, if you’re not satisfied with the current in-place editor, you can create your own custom in-place editor and assign it to the InplaceEditorEventArgs.InplaceEditorEx property.

View Example

private void SchedulerControl1_InplaceEditorShowing(object sender, InplaceEditorEventArgs e) {
    e.InplaceEditorEx = new MyInplaceEditorControl(e.SchedulerInplaceEditorEventArgs);
}

View Example

public class MyInplaceEditorControl : ISchedulerInplaceEditorEx {
    MyInplaceEditor editor;
    Appointment appointment;
    SchedulerControl control;

    public MyInplaceEditorControl(SchedulerInplaceEditorEventArgs inplaceEditorArgs) {
        this.appointment = inplaceEditorArgs.ViewInfo.Appointment;
        this.control = inplaceEditorArgs.Control;
        CreateEditor(inplaceEditorArgs);
    }

    MyInplaceEditor Editor { get { return editor; } }
    Appointment Appointment { get { return appointment; } }
    SchedulerControl Control { get { return control; } }

    public event EventHandler CommitChanges;
    public event EventHandler RollbackChanges;

    void CreateEditor(SchedulerInplaceEditorEventArgs inplaceEditorArgs) {
        this.editor = new MyInplaceEditor(inplaceEditorArgs);
    }

    // Interface implementation 
    public void Dispose() {
        Dispose(true);
        GC.SuppressFinalize(this);
    }
    ~MyInplaceEditorControl() {
        Dispose(false);
    }
    protected virtual void Dispose(bool disposing) {
        if (disposing) {
            if (Editor != null) {
                Editor.Dispose();
                this.editor = null;
            }
            this.appointment = null;
        }
    }
    public virtual void Activate() {
        Editor.FillForm(control, appointment);
        SubscribeEditorEvents();
        Editor.Show(Control.FindForm());
    }
    public virtual void Deactivate() {
        UnsibscribeEditorEvents();
        Editor.Close();
    }
    public virtual void ApplyChanges() {
        Editor.ApplyChanges();
    }
    protected internal virtual void SubscribeEditorEvents() {
        Editor.FormClosed += new FormClosedEventHandler(Editor_FormClosed);
        Editor.Deactivate += new EventHandler(Editor_Deactivate);
        Editor.CommitChanges += new EventHandler(Editor_CommitChanges);
        Editor.RollbackChanges += new EventHandler(Editor_RollbackChanges);
    }

    protected internal virtual void UnsibscribeEditorEvents() {
        Editor.FormClosed -= new FormClosedEventHandler(Editor_FormClosed);
        Editor.Deactivate -= new EventHandler(Editor_Deactivate);
        Editor.CommitChanges -= new EventHandler(Editor_CommitChanges);
        Editor.RollbackChanges -= new EventHandler(Editor_RollbackChanges);
    }
    void Editor_FormClosed(object sender, FormClosedEventArgs e) {
        OnCommitChanges();
    }
    void Editor_Deactivate(object sender, EventArgs e) {
        OnCommitChanges();
    }
    void Editor_RollbackChanges(object sender, EventArgs e) {
        OnRollbackChanges();
    }
    void Editor_CommitChanges(object sender, EventArgs e) {
        OnCommitChanges();
    }
    protected internal virtual void TextBox_LostFocus(object sender, EventArgs e) {
        Editor.Close();
        OnCommitChanges();
    }
    protected internal virtual void OnRollbackChanges() {
        if (RollbackChanges != null)
            RollbackChanges(this, EventArgs.Empty);
    }
    protected internal virtual void OnCommitChanges() {
        RaiseCommitChanges();
    }
    protected internal virtual void RaiseCommitChanges() {
        if (CommitChanges != null)
            CommitChanges(this, EventArgs.Empty);
    }
}

Also available is the InplaceEditorEventArgs.InplaceEditor property that is intended for backward compatibility with editors that implement the ISchedulerInplaceEditor interface.

See Also