' Developer Express Code Central Example:
' How to create a PropertyEditor based on the XtraRichEdit control
' 
' Take special note that this editor is intended to be used for a simple and most
' common scenario when only one text property in a Detail View is edited with the
' help of the XtraRichEdit control. Other scenarios are not supported in this
' example and are required to be implemented manually. For example, if there are
' more than one property, edited with this editor in a Detail View, then there may
' be problems with merging in ribbons. See the issue for more detailed
' information. See Also: Implement Custom Property Editors How to: Implement a
' Property Editor for Windows Forms Applications XtraRichEdit Home
' 
' You can find sample updates and versions for different programming languages here:
' http://www.devexpress.com/example=E1509

Imports Microsoft.VisualBasic
Imports System
Imports DevExpress.XtraEditors
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraBars

Partial Public Class RichEditUserControl
    Inherits XtraUserControl

    Private _EnterMoveNextControl As Boolean
    Public Sub New()
        InitializeComponent()
        Me.richEditControl_Renamed.Document.Sections(0).Page.PaperKind = System.Drawing.Printing.PaperKind.A4
    End Sub

    Public Property EnterMoveNextControl As Boolean
        Get
            Return _EnterMoveNextControl
        End Get
        Set(value As Boolean)
            _EnterMoveNextControl = value
        End Set
    End Property
    Public ReadOnly Property RichEditControl() As RichEditControl
        Get
            Return (Me.richEditControl_Renamed)
        End Get
    End Property
    Public ReadOnly Property RibbonControl() As RibbonControl
        Get
            Return Me.ribbonControl1
        End Get
    End Property
    Public Property RtfText() As String
        Get
            If richEditControl_Renamed IsNot Nothing Then
                Return richEditControl_Renamed.RtfText
            End If
            Return String.Empty
        End Get
        Set(ByVal value As String)
            If richEditControl_Renamed IsNot Nothing Then
                richEditControl_Renamed.RtfText = value
            End If
        End Set
    End Property
    Public Property MailingDataSource As Object
        Get
            Return Me.richEditControl_Renamed.Options.MailMerge.DataSource
        End Get
        Set(value As Object)
            Me.richEditControl_Renamed.Options.MailMerge.DataSource = value
        End Set
    End Property
    Public ReadOnly Property MailingInsertItemLink As DevExpress.XtraBars.PopupMenu
        Get
            Dim _RichEditUserControl As RichEditUserControl = TryCast(Me.RichEditControl.GetContainerControl, RichEditUserControl)
            Dim _InsertMergeFieldItem As DevExpress.XtraRichEdit.UI.InsertMergeFieldItem = TryCast(_RichEditUserControl.InsertMergeFieldItem1, DevExpress.XtraRichEdit.UI.InsertMergeFieldItem)
            Dim _PopupMenu As PopupMenu = TryCast(_InsertMergeFieldItem.DropDownControl, PopupMenu)

            Return _PopupMenu
        End Get

    End Property
End Class
