StrataFrame Forum

Extending the TextEdit Control

http://forum.strataframe.net/Topic22911.aspx

By Bill Cunnien - 4/28/2009

I have successfully extended the DevEx TextEdit control for use in my application. It is actually the control that is already extended by SF. When I drop it on a form that already has a primary BO assigned, the BusinessObject property is not set to that BO. The non-extended version of the control will fill this property in properly. How do I add that functionality to my extended control?



Thanks!

Bill
By Trent L. Taylor - 4/29/2009

You can look at the SF source code to see how this is done on the BusinessObject property.  Below is the code:

''' <summary>
''' The business object that is used to bind the data to this field
''' </summary>
''' <value></value>
''' <remarks></remarks>
<Category(EDITOR_CATEGORY), _
DefaultValue(CType(Nothing, Object)), _
Description(EDITOR_BUSINESSOBJECT_DESC)> _
Public Property BusinessObject() As BusinessLayerBase Implements IBusinessBindable.BusinessObject
    Get
        '-- Set the business object to the forms primary business object
        If Not _BusinessObjectEvaluated Then
            _BusinessObjectEvaluated = True
            Try
                BusinessBasics.DefaultBusinessObjectToFormPrimary(Me.DesignMode, _BusinessObject, CType(Me.GetService(GetType(System.ComponentModel.Design.IDesignerHost)), System.ComponentModel.Design.IDesignerHost))
            Catch ex As Exception
            End Try
        End If

        Return _BusinessObject
    End Get
    Set(ByVal value As BusinessLayerBase)
        '-- If the business object is being removed, then make sure it is no longer bound
        If (value Is Nothing) AndAlso (_BusinessObject IsNot Nothing) Then
            Me._BusinessObject.RemoveFromListOfBoundControls(Me)
        End If

        If (Not Me.DesignMode) AndAlso (value IsNot Nothing) Then
            value.AddToListOfBoundControls(Me)
        End If

        _BusinessObject = CType(value, BusinessLayer)
    End Set
End Property

By Bill Cunnien - 4/29/2009

So, if I inherit from MicroFour.StrataFrame.UI.Windows.Forms.DevEx.TextEdit do I need to implement IBusinessBindable and IInitializeBusinessObject interfaces in my own extended control?



This is the first control that I have extended. Sorry for my greenhorn questions.

Bill
By Trent L. Taylor - 4/29/2009

It should already have it implemented, so you may need to override the BusinessObject property to add additional logic to do this.  No problems on the questions, this is how you really learn what goes on under the hood.