Back to Devexpress

AppointmentLabelEdit Class

windowsforms-devexpress-dot-xtrascheduler-dot-ui.md

latest8.9 KB
Original Source

AppointmentLabelEdit Class

The image combo box control used to select appointment labels in appointment editing dialogs.

Namespace : DevExpress.XtraScheduler.UI

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
[ComVisible(false)]
[DXLicenseWinForms]
public class AppointmentLabelEdit :
    ImageComboBoxEdit
vb
<ComVisible(False)>
<DXLicenseWinForms>
Public Class AppointmentLabelEdit
    Inherits ImageComboBoxEdit

Remarks

The AppointmentLabelEdit represents a combo box editor with images displayed along with text captions. To link it to a SchedulerStorage, you should set its Storage property to that component. When dropped onto a form that contains a Scheduler control, it links itself to a scheduler storage automatically.

The combo box loads information about AppointmentLabel objects and displays the properties of each object as follows:

The control tracks the AppointmentLabelCollection changes. You may update the information manually by calling the AppointmentLabelEdit.RefreshData method.

The common appearance of the AppointmentLabelEdit is shown in the picture below.

Example

The following example demonstrates how to create a custom form to change the appointment’s label, status and resource. It is intended to illustrate XtraScheduler controls used for editing a non-recurring appointment. For information on how to substitute the standard form with a custom one, please refer to the Getting Started tutorial.

The example below declares a form constructor with parameters - a scheduler control and a current appointment. For this example to work correctly, the form should contain the following auxiliary controls:

You should also add the btnOk button, which is used to confirm the chosen settings and to close the form.

csharp
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.UI;
// ...

public partial class AppointmentForm : Form
    {
    SchedulerControl control;
    SchedulerStorage storage;
    AppointmentFormController controller;

    public AppointmentForm(SchedulerControl control, Appointment apt)
    {
    // The appointment editing should be performed 
    // via the AppointmentFormController instance.
            this.controller = CreateController(control, apt);

            InitializeComponent();

            this.control = control;
            this.storage = control.Storage;

            UpdateForm();
        }

        protected virtual AppointmentFormController 
            CreateController(SchedulerControl control, Appointment apt)
        {
            return new AppointmentFormController(control, apt);
        }

        // Fill in the controls with initial values.
        protected virtual void UpdateForm()
        {
            edtStatus.Storage = storage;
            edtStatus.Status = controller.GetStatus();

            edtResources.Storage = control.Storage;
            edtResources.ResourceId = controller.ResourceId;

            edtLabel.Storage = storage;
            edtLabel.Label = controller.GetLabel();

            // We can change resources only for base appointments.
            edtResources.Enabled = controller.CanEditResource;
        }

       // User actions are tracked by the controller.
       private void edtLabel_EditValueChanged(object sender, EventArgs e)
        {
            controller.SetLabel(edtLabel.Label);
        }

        private void edtResources_EditValueChanged(object sender, EventArgs e)
        {
            controller.ResourceId = edtResources.ResourceId;
        }

        private void edtStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            controller.SetStatus(edtStatus.Status);
        }

        // Confirm the changes and write them back.
        private void btnOk_Click(object sender, EventArgs e)
        {
            controller.ApplyChanges();
            this.DialogResult = Windows.Forms.DialogResult.OK;
        }

    }
vb
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.UI
' ...

Public Class AppointmentForm
    Inherits Form
    Private control As SchedulerControl
    Private storage As SchedulerStorage
    Private controller As AppointmentFormController

    Public Sub New(ByVal control As SchedulerControl, ByVal apt As Appointment)
        MyBase.New()

        ' The appointment editing should be performed 
        ' via the AppointmentFormController instance.
        Me.controller = CreateController(control, apt)
        InitializeComponent()
        Me.control = control
        Me.storage = control.Storage
        UpdateForm()
    End Sub

    Protected Overridable Function CreateController(ByVal control As SchedulerControl, _
        ByVal apt As Appointment) As AppointmentFormController

        Return New AppointmentFormController(control, apt)
    End Function

    ' Fill in the controls with initial values.
    Protected Overridable Sub UpdateForm()
        edtStatus.Storage = storage
        edtStatus.Status = controller.GetStatus
        edtResources.Storage = control.Storage
        edtResources.ResourceId = controller.ResourceId
        edtLabel.Storage = storage
        edtLabel.Label = controller.GetLabel
        'We can change resources only for base appointments.
        edtResources.Enabled = controller.CanEditResource
    End Sub

    ' User actions are tracked by the controller.
    Private Sub edtLabel_EditValueChanged(ByVal sender As Object, _
        ByVal e As EventArgs) Handles edtLabel.EditValueChanged

        controller.SetLabel(edtLabel.Label)
    End Sub

    Private Sub edtResources_EditValueChanged(ByVal sender As Object, _
        ByVal e As EventArgs) Handles edtResources.EditValueChanged

        controller.ResourceId = edtResources.ResourceId
    End Sub

    Private Sub edtStatus_SelectedIndexChanged(ByVal sender As Object, _
        ByVal e As EventArgs) Handles edtStatus.EditValueChanged

        controller.SetStatus(edtStatus.Status)
    End Sub

    ' Confirm the changes and write them back.
    Private Sub btnOk_Click(ByVal sender As Object, _
        ByVal e As EventArgs) Handles btnOk.Click
        controller.ApplyChanges()
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub
End Class

Implements

IXtraResizableControl

Inheritance

Show 15 items

Object MarshalByRefObject Component Control DevExpress.XtraEditors.XtraControl ControlBase BaseControl BaseEdit TextEdit ButtonEdit PopupBaseEdit PopupBaseAutoSearchEdit ComboBoxEdit ImageComboBoxEdit AppointmentLabelEdit

See Also

AppointmentLabelEdit Members

DevExpress.XtraScheduler.UI Namespace