Binding to a Custom Field


Author
Message
Larry Caylor
Larry Caylor
StrataFrame VIP (1.9K reputation)StrataFrame VIP (1.9K reputation)StrataFrame VIP (1.9K reputation)StrataFrame VIP (1.9K reputation)StrataFrame VIP (1.9K reputation)StrataFrame VIP (1.9K reputation)StrataFrame VIP (1.9K reputation)StrataFrame VIP (1.9K reputation)StrataFrame VIP (1.9K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

Is it possible to create a custom field in a BO, that is not part of the underlying DataSource,  that I can bind to?  I tried adding the following custom field to my BO.

 

Private mVerifyPassword As String = ""

 

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("Verify Password"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public Property UserCF_VerifyPassword() As System.String

   Get

     Return mVerifyPassword

   End Get

   Set(ByVal value As System.String)

      If mVerifyPassword = value.Trim Then Exit Property

      mVerifyPassword = value.Trim

Me.OnFieldPropertyChanged(Me, _

 New UserFieldChangedEventArgsmVerifyPassword))

   End Set

End Property

 

I can bind to it in the designer but when I go to run the program I get the following error:

 

BusinessLayerException

                An error occurred while refreshing the data from field 'UserBO.UserCF_VerifyPassword' to property 'Text' on control 'txtVerifyPassword.'  Are you missing FieldPropertyDescriptor for a custom property?

ArgumentException

                Cannot bind to the property or column UserCF_VerifyPassword on the DataSource.

Parameter name: dataMember

 

Source     : MicroFour StrataFrame Business

 

Stack Trace:

   at System.Windows.Forms.BindToObject.CheckBinding()

   at System.Windows.Forms.BindToObject.SetBindingManagerBase(BindingManagerBase lManager)

   at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase)

   at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding)

   at System.Windows.Forms.BindingsCollection.Add(Binding binding) ...

 

-Larry

Reply
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You can always start by copying one of the descriptor classes from the .designer.cs (or .designer.vb) file and go from there. Within the class, you will only need to change your _PropertyType value to the return type of the property and change the Get and Set methods to get and return the proper property respectively. And you'll also need to change the name of the class Smile And then, just like Trent said, make sure you return the value as part of the collection returned from the GetCustomBindablePropertyDescriptors() method.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search